react-native-iap 14.4.42 → 14.4.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ import com.margelo.nitro.core.Promise
6
6
  import dev.hyo.openiap.AndroidSubscriptionOfferInput
7
7
  import dev.hyo.openiap.DeepLinkOptions as OpenIapDeepLinkOptions
8
8
  import dev.hyo.openiap.FetchProductsResult
9
+ import dev.hyo.openiap.FetchProductsResultAll
9
10
  import dev.hyo.openiap.FetchProductsResultProducts
10
11
  import dev.hyo.openiap.FetchProductsResultSubscriptions
11
12
  import dev.hyo.openiap.OpenIapError as OpenIAPError
@@ -329,7 +330,22 @@ class HybridRnIap : HybridRnIapSpec() {
329
330
 
330
331
  try {
331
332
  initConnection(null).await()
332
- withContext(Dispatchers.Main) { runCatching { openIap.setActivity(context.currentActivity) } }
333
+
334
+ // Ensure Activity is available for purchase flow
335
+ val activity = withContext(Dispatchers.Main) {
336
+ runCatching { context.currentActivity }
337
+ .getOrNull()
338
+ }
339
+
340
+ if (activity == null) {
341
+ RnIapLog.warn("requestPurchase: Activity is null - cannot start purchase flow")
342
+ sendPurchaseError(toErrorResult(OpenIAPError.MissingCurrentActivity))
343
+ return@async defaultResult
344
+ }
345
+
346
+ withContext(Dispatchers.Main) {
347
+ openIap.setActivity(activity)
348
+ }
333
349
 
334
350
  val missingSkus = androidRequest.skus.filterNot { productTypeBySku.containsKey(it) }
335
351
  if (missingSkus.isNotEmpty()) {
@@ -727,6 +743,7 @@ class HybridRnIap : HybridRnIapSpec() {
727
743
  private fun FetchProductsResult.productsOrEmpty(): List<ProductCommon> = when (this) {
728
744
  is FetchProductsResultProducts -> this.value.orEmpty().filterIsInstance<ProductCommon>()
729
745
  is FetchProductsResultSubscriptions -> this.value.orEmpty().filterIsInstance<ProductCommon>()
746
+ is FetchProductsResultAll -> this.value.orEmpty().filterIsInstance<ProductCommon>()
730
747
  }
731
748
 
732
749
  private fun dev.hyo.openiap.RequestPurchaseResult?.purchasesOrEmpty(): List<OpenIapPurchase> = when (this) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "apple": "1.2.36",
3
- "google": "1.3.6",
3
+ "google": "1.3.7",
4
4
  "gql": "1.2.5"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "14.4.42",
3
+ "version": "14.4.44",
4
4
  "description": "React Native In-App Purchases module for iOS and Android using Nitro",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",