react-native-iap 15.2.3 → 15.3.0
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 +31 -51
- package/android/build.gradle +92 -22
- package/android/gradle.properties +5 -1
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +24 -8
- package/android/src/main/java/com/margelo/nitro/iap/RnIapLog.kt +3 -1
- package/ios/HybridRnIap.swift +172 -73
- package/lib/module/hooks/useIAP.js +1 -1
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +138 -165
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +22 -16
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +61 -90
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +5 -16
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +63 -49
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitro.json +0 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +11 -6
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JPurchaseUpdatedListenerOptions.hpp +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +4 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseUpdatedListenerOptions.kt +38 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +9 -4
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -2
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +8 -12
- package/nitrogen/generated/ios/swift/PurchaseUpdatedListenerOptions.swift +61 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +5 -2
- package/nitrogen/generated/shared/c++/PurchaseUpdatedListenerOptions.hpp +85 -0
- package/openiap-versions.json +3 -3
- package/package.json +4 -6
- package/src/hooks/useIAP.ts +23 -15
- package/src/index.ts +198 -215
- package/src/specs/RnIap.nitro.ts +10 -18
- package/src/types.ts +66 -49
package/src/hooks/useIAP.ts
CHANGED
|
@@ -48,6 +48,7 @@ import type {
|
|
|
48
48
|
Product,
|
|
49
49
|
Purchase,
|
|
50
50
|
PurchaseError,
|
|
51
|
+
PurchaseUpdatedListenerOptions,
|
|
51
52
|
ProductSubscription,
|
|
52
53
|
} from '../types';
|
|
53
54
|
import type {MutationFinishTransactionArgs} from '../types';
|
|
@@ -86,7 +87,7 @@ type UseIap = {
|
|
|
86
87
|
* @remarks **Critical:** Android purchases must be finalized within 3 days or Google
|
|
87
88
|
* auto-refunds. iOS unfinished transactions replay on every app launch.
|
|
88
89
|
*
|
|
89
|
-
* @see {@link https://
|
|
90
|
+
* @see {@link https://openiap.dev/docs/apis/finish-transaction}
|
|
90
91
|
*/
|
|
91
92
|
finishTransaction: (args: MutationFinishTransactionArgs) => Promise<void>;
|
|
92
93
|
/**
|
|
@@ -117,7 +118,7 @@ type UseIap = {
|
|
|
117
118
|
* }, [availablePurchases, finishTransaction]);
|
|
118
119
|
* ```
|
|
119
120
|
*
|
|
120
|
-
* @see {@link https://
|
|
121
|
+
* @see {@link https://openiap.dev/docs/apis/get-available-purchases}
|
|
121
122
|
*/
|
|
122
123
|
getAvailablePurchases: (options?: PurchaseOptions) => Promise<void>;
|
|
123
124
|
/**
|
|
@@ -147,7 +148,7 @@ type UseIap = {
|
|
|
147
148
|
* @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
|
|
148
149
|
* (`requestPurchase`), which are event-based.
|
|
149
150
|
*
|
|
150
|
-
* @see {@link https://
|
|
151
|
+
* @see {@link https://openiap.dev/docs/apis/fetch-products}
|
|
151
152
|
*/
|
|
152
153
|
fetchProducts: (params: {
|
|
153
154
|
skus: string[];
|
|
@@ -178,13 +179,13 @@ type UseIap = {
|
|
|
178
179
|
* @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
|
|
179
180
|
* {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
|
|
180
181
|
*
|
|
181
|
-
* @see {@link https://
|
|
182
|
+
* @see {@link https://openiap.dev/docs/apis/request-purchase}
|
|
182
183
|
*/
|
|
183
184
|
requestPurchase: (params: RequestPurchaseProps) => Promise<void>;
|
|
184
185
|
/**
|
|
185
186
|
* @deprecated Use `verifyPurchase` instead. This function will be removed in a future version.
|
|
186
187
|
*
|
|
187
|
-
* @see {@link https://
|
|
188
|
+
* @see {@link https://openiap.dev/docs/apis/validate-receipt}
|
|
188
189
|
*/
|
|
189
190
|
validateReceipt: (
|
|
190
191
|
options: VerifyPurchaseProps,
|
|
@@ -192,7 +193,7 @@ type UseIap = {
|
|
|
192
193
|
/**
|
|
193
194
|
* Verify a purchase against your own backend (returns isValid + raw store metadata).
|
|
194
195
|
*
|
|
195
|
-
* @see {@link https://
|
|
196
|
+
* @see {@link https://openiap.dev/docs/features/validation#verify-purchase}
|
|
196
197
|
*/
|
|
197
198
|
verifyPurchase: (
|
|
198
199
|
options: VerifyPurchaseProps,
|
|
@@ -200,7 +201,7 @@ type UseIap = {
|
|
|
200
201
|
/**
|
|
201
202
|
* Verify via a managed provider — currently only `iapkit` (IAPKit). The PurchaseVerificationProvider enum exposes no other provider literal today.
|
|
202
203
|
*
|
|
203
|
-
* @see {@link https://
|
|
204
|
+
* @see {@link https://openiap.dev/docs/features/validation#verify-purchase-with-provider}
|
|
204
205
|
*/
|
|
205
206
|
verifyPurchaseWithProvider: (
|
|
206
207
|
options: VerifyPurchaseWithProviderProps,
|
|
@@ -208,25 +209,25 @@ type UseIap = {
|
|
|
208
209
|
/**
|
|
209
210
|
* Restore non-consumable and active subscription purchases.
|
|
210
211
|
*
|
|
211
|
-
* @see {@link https://
|
|
212
|
+
* @see {@link https://openiap.dev/docs/apis/restore-purchases}
|
|
212
213
|
*/
|
|
213
214
|
restorePurchases: (options?: PurchaseOptions) => Promise<void>;
|
|
214
215
|
/**
|
|
215
216
|
* Read the App Store-promoted product, if any.
|
|
216
217
|
*
|
|
217
|
-
* @see {@link https://
|
|
218
|
+
* @see {@link https://openiap.dev/docs/apis/ios/get-promoted-product-ios}
|
|
218
219
|
*/
|
|
219
220
|
getPromotedProductIOS: () => Promise<Product | null>;
|
|
220
221
|
/**
|
|
221
222
|
* Buy the currently promoted product.
|
|
222
223
|
*
|
|
223
|
-
* @see {@link https://
|
|
224
|
+
* @see {@link https://openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios}
|
|
224
225
|
*/
|
|
225
226
|
requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;
|
|
226
227
|
/**
|
|
227
228
|
* Get details of all currently active subscriptions.
|
|
228
229
|
*
|
|
229
|
-
* @see {@link https://
|
|
230
|
+
* @see {@link https://openiap.dev/docs/apis/get-active-subscriptions}
|
|
230
231
|
*/
|
|
231
232
|
getActiveSubscriptions: (
|
|
232
233
|
subscriptionIds?: string[],
|
|
@@ -234,7 +235,7 @@ type UseIap = {
|
|
|
234
235
|
/**
|
|
235
236
|
* Check whether the user has any active subscription.
|
|
236
237
|
*
|
|
237
|
-
* @see {@link https://
|
|
238
|
+
* @see {@link https://openiap.dev/docs/apis/has-active-subscriptions}
|
|
238
239
|
*/
|
|
239
240
|
hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;
|
|
240
241
|
/**
|
|
@@ -247,19 +248,19 @@ type UseIap = {
|
|
|
247
248
|
/**
|
|
248
249
|
* Check whether alternative billing is available for the user.
|
|
249
250
|
*
|
|
250
|
-
* @see {@link https://
|
|
251
|
+
* @see {@link https://openiap.dev/docs/apis/android/check-alternative-billing-availability-android}
|
|
251
252
|
*/
|
|
252
253
|
checkAlternativeBillingAvailabilityAndroid?: () => Promise<boolean>;
|
|
253
254
|
/**
|
|
254
255
|
* Display Google's alternative billing information dialog.
|
|
255
256
|
*
|
|
256
|
-
* @see {@link https://
|
|
257
|
+
* @see {@link https://openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}
|
|
257
258
|
*/
|
|
258
259
|
showAlternativeBillingDialogAndroid?: () => Promise<boolean>;
|
|
259
260
|
/**
|
|
260
261
|
* Create a reporting token for an alternative billing flow.
|
|
261
262
|
*
|
|
262
|
-
* @see {@link https://
|
|
263
|
+
* @see {@link https://openiap.dev/docs/apis/android/create-alternative-billing-token-android}
|
|
263
264
|
*/
|
|
264
265
|
createAlternativeBillingTokenAndroid?: (
|
|
265
266
|
sku?: string,
|
|
@@ -268,6 +269,12 @@ type UseIap = {
|
|
|
268
269
|
|
|
269
270
|
export interface UseIapOptions {
|
|
270
271
|
onPurchaseSuccess?: (purchase: Purchase) => void;
|
|
272
|
+
/**
|
|
273
|
+
* Options for the purchase success listener. iOS defaults to suppressing
|
|
274
|
+
* StoreKit replay events for the same transaction ID; set
|
|
275
|
+
* `dedupeTransactionIOS` to false only for diagnostics.
|
|
276
|
+
*/
|
|
277
|
+
purchaseUpdatedListenerOptions?: PurchaseUpdatedListenerOptions | null;
|
|
271
278
|
onPurchaseError?: (error: PurchaseError) => void;
|
|
272
279
|
/** Callback for non-purchase errors (fetchProducts, getAvailablePurchases, etc.) */
|
|
273
280
|
onError?: (error: Error) => void;
|
|
@@ -593,6 +600,7 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
593
600
|
optionsRef.current.onPurchaseSuccess(purchase);
|
|
594
601
|
}
|
|
595
602
|
},
|
|
603
|
+
optionsRef.current?.purchaseUpdatedListenerOptions,
|
|
596
604
|
);
|
|
597
605
|
}
|
|
598
606
|
|