react-native-iap 14.6.0-rc.2 â 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.
- package/README.md +0 -1
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +19 -1
- package/ios/HybridRnIap.swift +3 -0
- package/openiap-versions.json +2 -2
- package/package.json +1 -1
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/plugin/build/src/withIAP.d.ts +0 -3
- package/plugin/build/src/withIAP.js +0 -81
- package/plugin/build/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<img src="https://hyochan.github.io/react-native-iap/img/icon.png" alt="React Native IAP Logo" width="150" />
|
|
5
5
|
|
|
6
6
|
[](https://npmjs.org/package/react-native-iap)
|
|
7
|
-
[](https://npmjs.org/package/react-native-iap)
|
|
8
7
|
[](https://npmjs.org/package/react-native-iap)
|
|
9
8
|
[](https://opencollective.com/react-native-iap)
|
|
10
9
|
[](https://github.com/hyochan/react-native-iap/actions/workflows/ci-test.yml)
|
|
@@ -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
|
-
|
|
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,
|
package/ios/HybridRnIap.swift
CHANGED
|
@@ -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/openiap-versions.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/
|
|
1
|
+
{"root":["./src/withIAP.ts"],"version":"5.9.2"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const config_plugins_1 = require("expo/config-plugins");
|
|
4
|
-
const pkg = require('../../package.json');
|
|
5
|
-
// Global flag to prevent duplicate logs
|
|
6
|
-
let hasLoggedPluginExecution = false;
|
|
7
|
-
const addLineToGradle = (content, anchor, lineToAdd, offset = 1) => {
|
|
8
|
-
const lines = content.split('\n');
|
|
9
|
-
const index = lines.findIndex((line) => line.match(anchor));
|
|
10
|
-
if (index === -1) {
|
|
11
|
-
console.warn(`Anchor "${anchor}" not found in build.gradle. Appending to end.`);
|
|
12
|
-
lines.push(lineToAdd);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
lines.splice(index + offset, 0, lineToAdd);
|
|
16
|
-
}
|
|
17
|
-
return lines.join('\n');
|
|
18
|
-
};
|
|
19
|
-
const modifyAppBuildGradle = (gradle) => {
|
|
20
|
-
let modified = gradle;
|
|
21
|
-
// Add billing library dependencies to app-level build.gradle
|
|
22
|
-
const billingDep = ` implementation "com.android.billingclient:billing-ktx:8.0.0"`;
|
|
23
|
-
const gmsDep = ` implementation "com.google.android.gms:play-services-base:18.1.0"`;
|
|
24
|
-
let hasAddedDependency = false;
|
|
25
|
-
if (!modified.includes(billingDep)) {
|
|
26
|
-
modified = addLineToGradle(modified, /dependencies\s*{/, billingDep);
|
|
27
|
-
hasAddedDependency = true;
|
|
28
|
-
}
|
|
29
|
-
if (!modified.includes(gmsDep)) {
|
|
30
|
-
modified = addLineToGradle(modified, /dependencies\s*{/, gmsDep, 1);
|
|
31
|
-
hasAddedDependency = true;
|
|
32
|
-
}
|
|
33
|
-
// Log only once and only if we actually added dependencies
|
|
34
|
-
if (hasAddedDependency && !hasLoggedPluginExecution) {
|
|
35
|
-
console.log('đ ī¸ react-native-iap: Added billing dependencies to build.gradle');
|
|
36
|
-
}
|
|
37
|
-
return modified;
|
|
38
|
-
};
|
|
39
|
-
const withIapAndroid = (config) => {
|
|
40
|
-
// Add IAP dependencies to app build.gradle
|
|
41
|
-
config = (0, config_plugins_1.withAppBuildGradle)(config, (config) => {
|
|
42
|
-
config.modResults.contents = modifyAppBuildGradle(config.modResults.contents);
|
|
43
|
-
return config;
|
|
44
|
-
});
|
|
45
|
-
config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
|
|
46
|
-
const manifest = config.modResults;
|
|
47
|
-
if (!manifest.manifest['uses-permission']) {
|
|
48
|
-
manifest.manifest['uses-permission'] = [];
|
|
49
|
-
}
|
|
50
|
-
const permissions = manifest.manifest['uses-permission'];
|
|
51
|
-
const billingPerm = { $: { 'android:name': 'com.android.vending.BILLING' } };
|
|
52
|
-
const alreadyExists = permissions.some((p) => p.$['android:name'] === 'com.android.vending.BILLING');
|
|
53
|
-
if (!alreadyExists) {
|
|
54
|
-
permissions.push(billingPerm);
|
|
55
|
-
if (!hasLoggedPluginExecution) {
|
|
56
|
-
console.log('â
Added com.android.vending.BILLING to AndroidManifest.xml');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
if (!hasLoggedPluginExecution) {
|
|
61
|
-
console.log('âšī¸ com.android.vending.BILLING already exists in AndroidManifest.xml');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return config;
|
|
65
|
-
});
|
|
66
|
-
return config;
|
|
67
|
-
};
|
|
68
|
-
const withIAP = (config, _props) => {
|
|
69
|
-
try {
|
|
70
|
-
const result = withIapAndroid(config);
|
|
71
|
-
// Set flag after first execution to prevent duplicate logs
|
|
72
|
-
hasLoggedPluginExecution = true;
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
config_plugins_1.WarningAggregator.addWarningAndroid('react-native-iap', `react-native-iap plugin encountered an error: ${error}`);
|
|
77
|
-
console.error('react-native-iap plugin error:', error);
|
|
78
|
-
return config;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
exports.default = (0, config_plugins_1.createRunOncePlugin)(withIAP, pkg.name, pkg.version);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../src/withiap.ts"],"version":"5.9.2"}
|