react-native-iap 15.2.4 → 15.3.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 +29 -49
- package/android/build.gradle +92 -22
- package/android/gradle.properties +5 -1
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/iap/RnIapLog.kt +3 -1
- package/ios/HybridRnIap.swift +12 -6
- package/lib/module/index.js +73 -158
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +15 -15
- package/lib/typescript/src/index.d.ts +59 -88
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +2 -15
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +47 -47
- package/nitro.json +0 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +7 -7
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/{JNitroPurchaseUpdatedListenerOptions.hpp → JPurchaseUpdatedListenerOptions.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/{NitroPurchaseUpdatedListenerOptions.kt → PurchaseUpdatedListenerOptions.kt} +5 -5
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +10 -10
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -3
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +4 -4
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +1 -1
- package/nitrogen/generated/ios/swift/{NitroPurchaseUpdatedListenerOptions.swift → PurchaseUpdatedListenerOptions.swift} +5 -5
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/{NitroPurchaseUpdatedListenerOptions.hpp → PurchaseUpdatedListenerOptions.hpp} +11 -11
- package/openiap-versions.json +2 -2
- package/package.json +4 -6
- package/src/hooks/useIAP.ts +15 -15
- package/src/index.ts +93 -204
- package/src/specs/RnIap.nitro.ts +2 -15
- package/src/types.ts +47 -47
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// PurchaseUpdatedListenerOptions.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
import NitroModules
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Represents an instance of `
|
|
11
|
+
* Represents an instance of `PurchaseUpdatedListenerOptions`, backed by a C++ struct.
|
|
12
12
|
*/
|
|
13
|
-
public typealias
|
|
13
|
+
public typealias PurchaseUpdatedListenerOptions = margelo.nitro.iap.PurchaseUpdatedListenerOptions
|
|
14
14
|
|
|
15
|
-
public extension
|
|
15
|
+
public extension PurchaseUpdatedListenerOptions {
|
|
16
16
|
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Create a new instance of `
|
|
19
|
+
* Create a new instance of `PurchaseUpdatedListenerOptions`.
|
|
20
20
|
*/
|
|
21
21
|
init(dedupeTransactionIOS: Variant_NullType_Bool?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__variant_nitro__NullType__bool__ in
|
|
@@ -33,8 +33,8 @@ namespace margelo::nitro::iap { struct NitroActiveSubscription; }
|
|
|
33
33
|
namespace margelo::nitro::iap { struct NitroPurchaseResult; }
|
|
34
34
|
// Forward declaration of `NitroFinishTransactionParams` to properly resolve imports.
|
|
35
35
|
namespace margelo::nitro::iap { struct NitroFinishTransactionParams; }
|
|
36
|
-
// Forward declaration of `
|
|
37
|
-
namespace margelo::nitro::iap { struct
|
|
36
|
+
// Forward declaration of `PurchaseUpdatedListenerOptions` to properly resolve imports.
|
|
37
|
+
namespace margelo::nitro::iap { struct PurchaseUpdatedListenerOptions; }
|
|
38
38
|
// Forward declaration of `NitroSubscriptionStatus` to properly resolve imports.
|
|
39
39
|
namespace margelo::nitro::iap { struct NitroSubscriptionStatus; }
|
|
40
40
|
// Forward declaration of `NitroReceiptValidationResultIOS` to properly resolve imports.
|
|
@@ -91,7 +91,7 @@ namespace margelo::nitro::iap { enum class ExternalPurchaseCustomLinkNoticeTypeI
|
|
|
91
91
|
#include "NitroPurchaseResult.hpp"
|
|
92
92
|
#include "NitroFinishTransactionParams.hpp"
|
|
93
93
|
#include <functional>
|
|
94
|
-
#include "
|
|
94
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
95
95
|
#include "NitroSubscriptionStatus.hpp"
|
|
96
96
|
#include "NitroReceiptValidationResultIOS.hpp"
|
|
97
97
|
#include "NitroReceiptValidationResultAndroid.hpp"
|
|
@@ -151,7 +151,7 @@ namespace margelo::nitro::iap {
|
|
|
151
151
|
virtual std::shared_ptr<Promise<std::vector<NitroActiveSubscription>>> getActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) = 0;
|
|
152
152
|
virtual std::shared_ptr<Promise<bool>> hasActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) = 0;
|
|
153
153
|
virtual std::shared_ptr<Promise<std::variant<bool, NitroPurchaseResult>>> finishTransaction(const NitroFinishTransactionParams& params) = 0;
|
|
154
|
-
virtual double addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener, const std::optional<
|
|
154
|
+
virtual double addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener, const std::optional<PurchaseUpdatedListenerOptions>& options) = 0;
|
|
155
155
|
virtual void addPurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) = 0;
|
|
156
156
|
virtual void removePurchaseUpdatedListener(double token) = 0;
|
|
157
157
|
virtual void removePurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) = 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// PurchaseUpdatedListenerOptions.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -37,34 +37,34 @@
|
|
|
37
37
|
namespace margelo::nitro::iap {
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* A struct which can be represented as a JavaScript object (
|
|
40
|
+
* A struct which can be represented as a JavaScript object (PurchaseUpdatedListenerOptions).
|
|
41
41
|
*/
|
|
42
|
-
struct
|
|
42
|
+
struct PurchaseUpdatedListenerOptions final {
|
|
43
43
|
public:
|
|
44
44
|
std::optional<std::variant<nitro::NullType, bool>> dedupeTransactionIOS SWIFT_PRIVATE;
|
|
45
45
|
|
|
46
46
|
public:
|
|
47
|
-
|
|
48
|
-
explicit
|
|
47
|
+
PurchaseUpdatedListenerOptions() = default;
|
|
48
|
+
explicit PurchaseUpdatedListenerOptions(std::optional<std::variant<nitro::NullType, bool>> dedupeTransactionIOS): dedupeTransactionIOS(dedupeTransactionIOS) {}
|
|
49
49
|
|
|
50
50
|
public:
|
|
51
|
-
friend bool operator==(const
|
|
51
|
+
friend bool operator==(const PurchaseUpdatedListenerOptions& lhs, const PurchaseUpdatedListenerOptions& rhs) = default;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
} // namespace margelo::nitro::iap
|
|
55
55
|
|
|
56
56
|
namespace margelo::nitro {
|
|
57
57
|
|
|
58
|
-
// C++
|
|
58
|
+
// C++ PurchaseUpdatedListenerOptions <> JS PurchaseUpdatedListenerOptions (object)
|
|
59
59
|
template <>
|
|
60
|
-
struct JSIConverter<margelo::nitro::iap::
|
|
61
|
-
static inline margelo::nitro::iap::
|
|
60
|
+
struct JSIConverter<margelo::nitro::iap::PurchaseUpdatedListenerOptions> final {
|
|
61
|
+
static inline margelo::nitro::iap::PurchaseUpdatedListenerOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
62
62
|
jsi::Object obj = arg.asObject(runtime);
|
|
63
|
-
return margelo::nitro::iap::
|
|
63
|
+
return margelo::nitro::iap::PurchaseUpdatedListenerOptions(
|
|
64
64
|
JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dedupeTransactionIOS")))
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::PurchaseUpdatedListenerOptions& arg) {
|
|
68
68
|
jsi::Object obj(runtime);
|
|
69
69
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "dedupeTransactionIOS"), JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::toJSI(runtime, arg.dedupeTransactionIOS));
|
|
70
70
|
return obj;
|
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.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",
|
|
@@ -41,18 +41,16 @@
|
|
|
41
41
|
],
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build:plugin": "tsc --build plugin",
|
|
44
|
-
"setup:expo": "cd example-expo && bun setup",
|
|
45
44
|
"example": "yarn workspace rn-iap-example",
|
|
46
45
|
"example:ios": "yarn workspace rn-iap-example ios",
|
|
47
46
|
"example:android": "yarn workspace rn-iap-example android",
|
|
48
47
|
"example:start": "yarn workspace rn-iap-example start",
|
|
49
|
-
"typecheck": "yarn typecheck:lib
|
|
48
|
+
"typecheck": "yarn typecheck:lib",
|
|
50
49
|
"typecheck:lib": "yarn tsc --noEmit",
|
|
51
|
-
"typecheck:expo": "cd example-expo && bun run typecheck",
|
|
52
50
|
"clean": "rm -rf android/build node_modules/**/android/build lib nitrogen/generated",
|
|
53
51
|
"lint": "eslint --ext .ts,.tsx,.js,.jsx src",
|
|
54
52
|
"lint:eslint": "eslint --fix 'src/**/*.{ts,tsx}' 'plugin/src/**/*.{ts,tsx}'",
|
|
55
|
-
"lint:prettier": "prettier --write \"**/*.{md,js,jsx,ts,tsx}\"
|
|
53
|
+
"lint:prettier": "prettier --write \"**/*.{md,js,jsx,ts,tsx}\"",
|
|
56
54
|
"lint:tsc": "tsc -p tsconfig.json --noEmit --skipLibCheck",
|
|
57
55
|
"lint:ci": "yarn lint:tsc && yarn lint:eslint && yarn lint:prettier",
|
|
58
56
|
"prepare": "npx tsx scripts/check-nitro-versions.ts && bob build && yarn nitrogen && yarn build:plugin",
|
|
@@ -61,7 +59,7 @@
|
|
|
61
59
|
"test": "jest --coverage",
|
|
62
60
|
"test:library": "jest --coverage",
|
|
63
61
|
"test:example": "yarn workspace rn-iap-example test --coverage",
|
|
64
|
-
"test:plugin": "
|
|
62
|
+
"test:plugin": "jest plugin --coverage",
|
|
65
63
|
"test:all": "yarn test:library && yarn test:example",
|
|
66
64
|
"test:ci": "jest --maxWorkers=2 --coverage",
|
|
67
65
|
"test:ci:example": "yarn workspace rn-iap-example test --coverage",
|
package/src/hooks/useIAP.ts
CHANGED
|
@@ -87,7 +87,7 @@ type UseIap = {
|
|
|
87
87
|
* @remarks **Critical:** Android purchases must be finalized within 3 days or Google
|
|
88
88
|
* auto-refunds. iOS unfinished transactions replay on every app launch.
|
|
89
89
|
*
|
|
90
|
-
* @see {@link https://
|
|
90
|
+
* @see {@link https://openiap.dev/docs/apis/finish-transaction}
|
|
91
91
|
*/
|
|
92
92
|
finishTransaction: (args: MutationFinishTransactionArgs) => Promise<void>;
|
|
93
93
|
/**
|
|
@@ -118,7 +118,7 @@ type UseIap = {
|
|
|
118
118
|
* }, [availablePurchases, finishTransaction]);
|
|
119
119
|
* ```
|
|
120
120
|
*
|
|
121
|
-
* @see {@link https://
|
|
121
|
+
* @see {@link https://openiap.dev/docs/apis/get-available-purchases}
|
|
122
122
|
*/
|
|
123
123
|
getAvailablePurchases: (options?: PurchaseOptions) => Promise<void>;
|
|
124
124
|
/**
|
|
@@ -148,7 +148,7 @@ type UseIap = {
|
|
|
148
148
|
* @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
|
|
149
149
|
* (`requestPurchase`), which are event-based.
|
|
150
150
|
*
|
|
151
|
-
* @see {@link https://
|
|
151
|
+
* @see {@link https://openiap.dev/docs/apis/fetch-products}
|
|
152
152
|
*/
|
|
153
153
|
fetchProducts: (params: {
|
|
154
154
|
skus: string[];
|
|
@@ -179,13 +179,13 @@ type UseIap = {
|
|
|
179
179
|
* @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
|
|
180
180
|
* {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
|
|
181
181
|
*
|
|
182
|
-
* @see {@link https://
|
|
182
|
+
* @see {@link https://openiap.dev/docs/apis/request-purchase}
|
|
183
183
|
*/
|
|
184
184
|
requestPurchase: (params: RequestPurchaseProps) => Promise<void>;
|
|
185
185
|
/**
|
|
186
186
|
* @deprecated Use `verifyPurchase` instead. This function will be removed in a future version.
|
|
187
187
|
*
|
|
188
|
-
* @see {@link https://
|
|
188
|
+
* @see {@link https://openiap.dev/docs/apis/validate-receipt}
|
|
189
189
|
*/
|
|
190
190
|
validateReceipt: (
|
|
191
191
|
options: VerifyPurchaseProps,
|
|
@@ -193,7 +193,7 @@ type UseIap = {
|
|
|
193
193
|
/**
|
|
194
194
|
* Verify a purchase against your own backend (returns isValid + raw store metadata).
|
|
195
195
|
*
|
|
196
|
-
* @see {@link https://
|
|
196
|
+
* @see {@link https://openiap.dev/docs/features/validation#verify-purchase}
|
|
197
197
|
*/
|
|
198
198
|
verifyPurchase: (
|
|
199
199
|
options: VerifyPurchaseProps,
|
|
@@ -201,7 +201,7 @@ type UseIap = {
|
|
|
201
201
|
/**
|
|
202
202
|
* Verify via a managed provider — currently only `iapkit` (IAPKit). The PurchaseVerificationProvider enum exposes no other provider literal today.
|
|
203
203
|
*
|
|
204
|
-
* @see {@link https://
|
|
204
|
+
* @see {@link https://openiap.dev/docs/features/validation#verify-purchase-with-provider}
|
|
205
205
|
*/
|
|
206
206
|
verifyPurchaseWithProvider: (
|
|
207
207
|
options: VerifyPurchaseWithProviderProps,
|
|
@@ -209,25 +209,25 @@ type UseIap = {
|
|
|
209
209
|
/**
|
|
210
210
|
* Restore non-consumable and active subscription purchases.
|
|
211
211
|
*
|
|
212
|
-
* @see {@link https://
|
|
212
|
+
* @see {@link https://openiap.dev/docs/apis/restore-purchases}
|
|
213
213
|
*/
|
|
214
214
|
restorePurchases: (options?: PurchaseOptions) => Promise<void>;
|
|
215
215
|
/**
|
|
216
216
|
* Read the App Store-promoted product, if any.
|
|
217
217
|
*
|
|
218
|
-
* @see {@link https://
|
|
218
|
+
* @see {@link https://openiap.dev/docs/apis/ios/get-promoted-product-ios}
|
|
219
219
|
*/
|
|
220
220
|
getPromotedProductIOS: () => Promise<Product | null>;
|
|
221
221
|
/**
|
|
222
222
|
* Buy the currently promoted product.
|
|
223
223
|
*
|
|
224
|
-
* @see {@link https://
|
|
224
|
+
* @see {@link https://openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios}
|
|
225
225
|
*/
|
|
226
226
|
requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;
|
|
227
227
|
/**
|
|
228
228
|
* Get details of all currently active subscriptions.
|
|
229
229
|
*
|
|
230
|
-
* @see {@link https://
|
|
230
|
+
* @see {@link https://openiap.dev/docs/apis/get-active-subscriptions}
|
|
231
231
|
*/
|
|
232
232
|
getActiveSubscriptions: (
|
|
233
233
|
subscriptionIds?: string[],
|
|
@@ -235,7 +235,7 @@ type UseIap = {
|
|
|
235
235
|
/**
|
|
236
236
|
* Check whether the user has any active subscription.
|
|
237
237
|
*
|
|
238
|
-
* @see {@link https://
|
|
238
|
+
* @see {@link https://openiap.dev/docs/apis/has-active-subscriptions}
|
|
239
239
|
*/
|
|
240
240
|
hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;
|
|
241
241
|
/**
|
|
@@ -248,19 +248,19 @@ type UseIap = {
|
|
|
248
248
|
/**
|
|
249
249
|
* Check whether alternative billing is available for the user.
|
|
250
250
|
*
|
|
251
|
-
* @see {@link https://
|
|
251
|
+
* @see {@link https://openiap.dev/docs/apis/android/check-alternative-billing-availability-android}
|
|
252
252
|
*/
|
|
253
253
|
checkAlternativeBillingAvailabilityAndroid?: () => Promise<boolean>;
|
|
254
254
|
/**
|
|
255
255
|
* Display Google's alternative billing information dialog.
|
|
256
256
|
*
|
|
257
|
-
* @see {@link https://
|
|
257
|
+
* @see {@link https://openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}
|
|
258
258
|
*/
|
|
259
259
|
showAlternativeBillingDialogAndroid?: () => Promise<boolean>;
|
|
260
260
|
/**
|
|
261
261
|
* Create a reporting token for an alternative billing flow.
|
|
262
262
|
*
|
|
263
|
-
* @see {@link https://
|
|
263
|
+
* @see {@link https://openiap.dev/docs/apis/android/create-alternative-billing-token-android}
|
|
264
264
|
*/
|
|
265
265
|
createAlternativeBillingTokenAndroid?: (
|
|
266
266
|
sku?: string,
|