react-native-iap 14.4.28 → 14.4.30

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.
package/NitroIap.podspec CHANGED
@@ -42,7 +42,8 @@ Pod::Spec.new do |s|
42
42
  s.dependency 'React-jsi'
43
43
  s.dependency 'React-callinvoker'
44
44
  # OpenIAP Apple for StoreKit 2 integration
45
- s.dependency 'openiap', apple_version
45
+ # Use ~> to allow patch updates (e.g., 1.2.30 -> 1.2.31, but not 1.3.0)
46
+ s.dependency 'openiap', "~> #{apple_version}"
46
47
 
47
48
  install_modules_dependencies(s)
48
49
  end
@@ -222,7 +222,9 @@ class HybridRnIap : HybridRnIapSpec() {
222
222
 
223
223
  val products: List<ProductCommon> = when (queryType) {
224
224
  ProductQueryType.All -> {
225
- val collected = linkedMapOf<String, ProductCommon>()
225
+ // Fetch both InApp and Subs products
226
+ val byId = mutableMapOf<String, ProductCommon>()
227
+
226
228
  listOf(ProductQueryType.InApp, ProductQueryType.Subs).forEach { kind ->
227
229
  RnIapLog.payload(
228
230
  "fetchProducts.native",
@@ -233,9 +235,15 @@ class HybridRnIap : HybridRnIapSpec() {
233
235
  "fetchProducts.native",
234
236
  fetched.map { mapOf("id" to it.id, "type" to it.type.rawValue) }
235
237
  )
236
- fetched.forEach { collected[it.id] = it }
238
+
239
+ // Collect products by ID (no duplicates possible in Play Billing)
240
+ fetched.forEach { product ->
241
+ byId.putIfAbsent(product.id, product)
242
+ }
237
243
  }
238
- collected.values.toList()
244
+
245
+ // Return products in the same order as input skusList
246
+ skusList.mapNotNull { byId[it] }
239
247
  }
240
248
  else -> {
241
249
  RnIapLog.payload(
@@ -247,7 +255,10 @@ class HybridRnIap : HybridRnIapSpec() {
247
255
  "fetchProducts.native",
248
256
  fetched.map { mapOf("id" to it.id, "type" to it.type.rawValue) }
249
257
  )
250
- fetched
258
+
259
+ // Preserve input order for non-All queries
260
+ val byId = fetched.associateBy { it.id }
261
+ skusList.mapNotNull { byId[it] }
251
262
  }
252
263
  }
253
264
 
@@ -65,10 +65,15 @@ enum RnIapHelper {
65
65
  if let typeIOS = dictionary["typeIOS"] as? String { product.typeIOS = typeIOS }
66
66
  if let familyShareable = boolValue(dictionary["isFamilyShareableIOS"]) { product.isFamilyShareableIOS = familyShareable }
67
67
  if let jsonRepresentation = dictionary["jsonRepresentationIOS"] as? String { product.jsonRepresentationIOS = jsonRepresentation }
68
- if let discounts = dictionary["discountsIOS"] as? [[String: Any]] {
69
- if let jsonData = try? JSONSerialization.data(withJSONObject: discounts, options: []),
70
- let jsonString = String(data: jsonData, encoding: .utf8) {
71
- product.discountsIOS = jsonString
68
+ // Handle discountsIOS - OpenIAP 1.2.30+ returns [[String: Any]] (non-nullable)
69
+ if let discountsArray = dictionary["discountsIOS"] as? [[String: Any]] {
70
+ do {
71
+ let jsonData = try JSONSerialization.data(withJSONObject: discountsArray, options: [])
72
+ if let jsonString = String(data: jsonData, encoding: .utf8) {
73
+ product.discountsIOS = jsonString
74
+ }
75
+ } catch {
76
+ NSLog("⚠️ [RnIapHelper] Failed to serialize discountsIOS: \(error)")
72
77
  }
73
78
  }
74
79
  if let subscriptionUnit = dictionary["subscriptionPeriodUnitIOS"] as? String { product.subscriptionPeriodUnitIOS = subscriptionUnit }
@@ -1,5 +1,5 @@
1
1
  {
2
- "apple": "1.2.29",
2
+ "apple": "1.2.30",
3
3
  "google": "1.3.2",
4
4
  "gql": "1.2.3"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "14.4.28",
3
+ "version": "14.4.30",
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",