expo-iap 2.7.7-rc.1 → 2.7.8
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/.copilot-instructions.md +26 -8
- package/.markdownlint.json +2 -5
- package/CHANGELOG.md +28 -1
- package/CONTRIBUTING.md +25 -2
- package/README.md +6 -6
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js.map +1 -1
- package/build/index.d.ts +14 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +37 -6
- package/build/index.js.map +1 -1
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js.map +1 -1
- package/build/useIap.d.ts +8 -2
- package/build/useIap.d.ts.map +1 -1
- package/build/useIap.js +4 -25
- package/build/useIap.js.map +1 -1
- package/package.json +1 -1
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/ExpoIap.types.ts +17 -8
- package/src/index.ts +76 -37
- package/src/modules/android.ts +2 -4
- package/src/modules/ios.ts +87 -47
- package/src/useIap.ts +18 -32
- package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
package/src/useIap.ts
CHANGED
|
@@ -15,9 +15,13 @@ import {
|
|
|
15
15
|
finishTransaction as finishTransactionInternal,
|
|
16
16
|
requestPurchase as requestPurchaseInternal,
|
|
17
17
|
requestProducts,
|
|
18
|
+
validateReceipt as validateReceiptInternal,
|
|
18
19
|
} from './';
|
|
19
|
-
import {
|
|
20
|
-
|
|
20
|
+
import {
|
|
21
|
+
syncIOS,
|
|
22
|
+
getPromotedProductIOS,
|
|
23
|
+
buyPromotedProductIOS,
|
|
24
|
+
} from './modules/ios';
|
|
21
25
|
|
|
22
26
|
// Types
|
|
23
27
|
import {
|
|
@@ -58,9 +62,15 @@ type UseIap = {
|
|
|
58
62
|
skus: string[];
|
|
59
63
|
type?: 'inapp' | 'subs';
|
|
60
64
|
}) => Promise<void>;
|
|
61
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use requestProducts({ skus, type: 'inapp' }) instead. This method will be removed in version 3.0.0.
|
|
67
|
+
* Note: This method internally uses requestProducts, so no deprecation warning is shown.
|
|
68
|
+
*/
|
|
62
69
|
getProducts: (skus: string[]) => Promise<void>;
|
|
63
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated Use requestProducts({ skus, type: 'subs' }) instead. This method will be removed in version 3.0.0.
|
|
72
|
+
* Note: This method internally uses requestProducts, so no deprecation warning is shown.
|
|
73
|
+
*/
|
|
64
74
|
getSubscriptions: (skus: string[]) => Promise<void>;
|
|
65
75
|
requestPurchase: (params: {
|
|
66
76
|
request: RequestPurchaseProps | RequestSubscriptionProps;
|
|
@@ -93,9 +103,7 @@ export interface UseIAPOptions {
|
|
|
93
103
|
export function useIAP(options?: UseIAPOptions): UseIap {
|
|
94
104
|
const [connected, setConnected] = useState<boolean>(false);
|
|
95
105
|
const [products, setProducts] = useState<Product[]>([]);
|
|
96
|
-
const [promotedProductsIOS] = useState<
|
|
97
|
-
ProductPurchase[]
|
|
98
|
-
>([]);
|
|
106
|
+
const [promotedProductsIOS] = useState<ProductPurchase[]>([]);
|
|
99
107
|
const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
|
|
100
108
|
const [purchaseHistories, setPurchaseHistories] = useState<ProductPurchase[]>(
|
|
101
109
|
[],
|
|
@@ -324,29 +332,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
324
332
|
isSub?: boolean;
|
|
325
333
|
},
|
|
326
334
|
) => {
|
|
327
|
-
|
|
328
|
-
return await validateReceiptIOS(sku);
|
|
329
|
-
} else if (Platform.OS === 'android') {
|
|
330
|
-
if (
|
|
331
|
-
!androidOptions ||
|
|
332
|
-
!androidOptions.packageName ||
|
|
333
|
-
!androidOptions.productToken ||
|
|
334
|
-
!androidOptions.accessToken
|
|
335
|
-
) {
|
|
336
|
-
throw new Error(
|
|
337
|
-
'Android validation requires packageName, productToken, and accessToken',
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
return await validateReceiptAndroid({
|
|
341
|
-
packageName: androidOptions.packageName,
|
|
342
|
-
productId: sku,
|
|
343
|
-
productToken: androidOptions.productToken,
|
|
344
|
-
accessToken: androidOptions.accessToken,
|
|
345
|
-
isSub: androidOptions.isSub,
|
|
346
|
-
});
|
|
347
|
-
} else {
|
|
348
|
-
throw new Error('Platform not supported');
|
|
349
|
-
}
|
|
335
|
+
return validateReceiptInternal(sku, androidOptions);
|
|
350
336
|
},
|
|
351
337
|
[],
|
|
352
338
|
);
|
|
@@ -387,14 +373,14 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
387
373
|
subscriptionsRef.current.promotedProductsIos =
|
|
388
374
|
promotedProductListenerIOS((product: Product) => {
|
|
389
375
|
setPromotedProductIOS(product);
|
|
390
|
-
|
|
376
|
+
|
|
391
377
|
if (optionsRef.current?.onPromotedProductIOS) {
|
|
392
378
|
optionsRef.current.onPromotedProductIOS(product);
|
|
393
379
|
}
|
|
394
380
|
});
|
|
395
381
|
}
|
|
396
382
|
}
|
|
397
|
-
}, [refreshSubscriptionStatus
|
|
383
|
+
}, [refreshSubscriptionStatus]);
|
|
398
384
|
|
|
399
385
|
useEffect(() => {
|
|
400
386
|
initIapWithSubscriptions();
|