react-native-iap 14.6.0 → 14.6.1

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.
@@ -1222,7 +1222,9 @@ class HybridRnIap : HybridRnIapSpec() {
1222
1222
  val propsMap = mutableMapOf<String, Any?>("provider" to providerString)
1223
1223
  params.iapkit?.let { iapkit ->
1224
1224
  val iapkitMap = mutableMapOf<String, Any?>()
1225
- iapkit.apiKey?.let { iapkitMap["apiKey"] = it }
1225
+ // Use provided apiKey, or fallback to AndroidManifest meta-data (set by config plugin)
1226
+ val apiKey = iapkit.apiKey ?: getIapkitApiKeyFromManifest()
1227
+ apiKey?.let { iapkitMap["apiKey"] = it }
1226
1228
  iapkit.google?.let { google ->
1227
1229
  iapkitMap["google"] = mapOf("purchaseToken" to google.purchaseToken)
1228
1230
  }
@@ -1656,6 +1658,22 @@ class HybridRnIap : HybridRnIapSpec() {
1656
1658
  }
1657
1659
  }
1658
1660
 
1661
+ /**
1662
+ * Read IAPKit API key from AndroidManifest.xml meta-data (set by config plugin).
1663
+ * Config plugin sets: <meta-data android:name="dev.iapkit.API_KEY" android:value="..." />
1664
+ */
1665
+ private fun getIapkitApiKeyFromManifest(): String? {
1666
+ return try {
1667
+ val appInfo = context.packageManager.getApplicationInfo(
1668
+ context.packageName,
1669
+ android.content.pm.PackageManager.GET_META_DATA
1670
+ )
1671
+ appInfo.metaData?.getString("dev.iapkit.API_KEY")
1672
+ } catch (e: Exception) {
1673
+ null
1674
+ }
1675
+ }
1676
+
1659
1677
  private fun toErrorResult(
1660
1678
  error: OpenIAPError,
1661
1679
  productId: String? = null,
@@ -364,8 +364,11 @@ class HybridRnIap: HybridRnIapSpec {
364
364
  var propsDict: [String: Any] = ["provider": params.provider.stringValue]
365
365
  if let iapkit = params.iapkit {
366
366
  var iapkitDict: [String: Any] = [:]
367
+ // Use provided apiKey, or fallback to Info.plist IAPKitAPIKey (set by config plugin)
367
368
  if let apiKey = iapkit.apiKey {
368
369
  iapkitDict["apiKey"] = apiKey
370
+ } else if let plistApiKey = Bundle.main.object(forInfoDictionaryKey: "IAPKitAPIKey") as? String {
371
+ iapkitDict["apiKey"] = plistApiKey
369
372
  }
370
373
  if let apple = iapkit.apple {
371
374
  iapkitDict["apple"] = ["jws": apple.jws]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "14.6.0",
3
+ "version": "14.6.1",
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",