react-native-iap 14.4.35 â 14.4.36-rc.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 +15 -0
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +3 -24
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/package.json +1 -1
- package/plugin/build/src/withIAP.d.ts +3 -0
- package/plugin/build/src/withIAP.js +81 -0
- package/plugin/build/tsconfig.tsbuildinfo +1 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,21 @@
|
|
|
15
15
|
<a href="https://openiap.dev"><img src="https://github.com/hyodotdev/openiap/blob/main/logo.png" alt="Open IAP" height="40" /></a>
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
+
## đ¨ Promotion
|
|
19
|
+
|
|
20
|
+
<div align="center">
|
|
21
|
+
<a href="https://hyodotdev.github.io/kstyled">
|
|
22
|
+
<img src="https://hyodotdev.github.io/kstyled/img/logo.png" alt="kstyled Logo" width="120" />
|
|
23
|
+
</a>
|
|
24
|
+
|
|
25
|
+
**Compile-time CSS-in-JS for React Native**
|
|
26
|
+
|
|
27
|
+
⨠Banishing runtime overhead, one style at a time with **[kstyled](https://hyodotdev.github.io/kstyled)** - fully type-safe styling that compiles away.
|
|
28
|
+
|
|
29
|
+
đ **[Explore kstyled â](https://hyodotdev.github.io/kstyled)**
|
|
30
|
+
|
|
31
|
+
</div>
|
|
32
|
+
|
|
18
33
|
## đ Documentation
|
|
19
34
|
|
|
20
35
|
**[đ Visit our comprehensive documentation site â](https://hyochan.github.io/react-native-iap)**
|
|
@@ -461,33 +461,12 @@ class HybridRnIap : HybridRnIapSpec() {
|
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
val result: List<OpenIapPurchase> = if (normalizedType != null) {
|
|
464
|
+
val typeEnum = parseProductQueryType(normalizedType)
|
|
464
465
|
RnIapLog.payload(
|
|
465
466
|
"getAvailablePurchases.native",
|
|
466
|
-
mapOf("type" to
|
|
467
|
+
mapOf("type" to typeEnum.rawValue)
|
|
467
468
|
)
|
|
468
|
-
|
|
469
|
-
// Get all purchases and filter manually
|
|
470
|
-
val allPurchases = openIap.getAvailablePurchases(null)
|
|
471
|
-
|
|
472
|
-
// Partition purchases to handle cases where product type is not yet cached
|
|
473
|
-
val (knownTypePurchases, unknownTypePurchases) = allPurchases.partition {
|
|
474
|
-
productTypeBySku.containsKey(it.productId)
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if (unknownTypePurchases.isNotEmpty()) {
|
|
478
|
-
RnIapLog.warn(
|
|
479
|
-
"getAvailablePurchases: Could not determine type for product IDs: " +
|
|
480
|
-
"${unknownTypePurchases.map { it.productId }.joinToString()}. " +
|
|
481
|
-
"These will be excluded from '$normalizedType' filtered lists. " +
|
|
482
|
-
"Call fetchProducts first to populate product type cache."
|
|
483
|
-
)
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
when (normalizedType) {
|
|
487
|
-
"in-app" -> knownTypePurchases.filter { productTypeBySku[it.productId] == "in-app" }
|
|
488
|
-
"subs" -> knownTypePurchases.filter { productTypeBySku[it.productId] == "subs" }
|
|
489
|
-
else -> allPurchases
|
|
490
|
-
}
|
|
469
|
+
openIap.getAvailableItems(typeEnum)
|
|
491
470
|
} else {
|
|
492
471
|
RnIapLog.payload("getAvailablePurchases.native", mapOf("type" to "all"))
|
|
493
472
|
openIap.getAvailablePurchases(null)
|
package/package.json
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/withiap.ts"],"version":"5.9.2"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/
|
|
1
|
+
{"root":["./src/withiap.ts"],"version":"5.9.2"}
|