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/index.ts
CHANGED
|
@@ -4,8 +4,8 @@ import {Platform} from 'react-native';
|
|
|
4
4
|
|
|
5
5
|
// Internal modules
|
|
6
6
|
import ExpoIapModule from './ExpoIapModule';
|
|
7
|
-
import {isProductIos} from './modules/ios';
|
|
8
|
-
import {isProductAndroid} from './modules/android';
|
|
7
|
+
import {isProductIos, validateReceiptIOS} from './modules/ios';
|
|
8
|
+
import {isProductAndroid, validateReceiptAndroid} from './modules/android';
|
|
9
9
|
|
|
10
10
|
// Types
|
|
11
11
|
import {
|
|
@@ -21,12 +21,8 @@ import {
|
|
|
21
21
|
isPlatformRequestProps,
|
|
22
22
|
isUnifiedRequestProps,
|
|
23
23
|
} from './ExpoIap.types';
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
} from './types/ExpoIapAndroid.types';
|
|
27
|
-
import {
|
|
28
|
-
PaymentDiscount,
|
|
29
|
-
} from './types/ExpoIapIos.types';
|
|
24
|
+
import {ProductPurchaseAndroid} from './types/ExpoIapAndroid.types';
|
|
25
|
+
import {PaymentDiscount} from './types/ExpoIapIos.types';
|
|
30
26
|
|
|
31
27
|
// Export all types
|
|
32
28
|
export * from './ExpoIap.types';
|
|
@@ -80,29 +76,31 @@ export const purchaseErrorListener = (
|
|
|
80
76
|
/**
|
|
81
77
|
* iOS-only listener for App Store promoted product events.
|
|
82
78
|
* This fires when a user taps on a promoted product in the App Store.
|
|
83
|
-
*
|
|
79
|
+
*
|
|
84
80
|
* @param listener - Callback function that receives the promoted product details
|
|
85
81
|
* @returns EventSubscription that can be used to unsubscribe
|
|
86
|
-
*
|
|
82
|
+
*
|
|
87
83
|
* @example
|
|
88
84
|
* ```typescript
|
|
89
85
|
* const subscription = promotedProductListenerIOS((product) => {
|
|
90
86
|
* console.log('Promoted product:', product);
|
|
91
87
|
* // Handle the promoted product
|
|
92
88
|
* });
|
|
93
|
-
*
|
|
89
|
+
*
|
|
94
90
|
* // Later, clean up
|
|
95
91
|
* subscription.remove();
|
|
96
92
|
* ```
|
|
97
|
-
*
|
|
93
|
+
*
|
|
98
94
|
* @platform iOS
|
|
99
95
|
*/
|
|
100
96
|
export const promotedProductListenerIOS = (
|
|
101
97
|
listener: (product: Product) => void,
|
|
102
98
|
) => {
|
|
103
99
|
if (Platform.OS !== 'ios') {
|
|
104
|
-
console.warn(
|
|
105
|
-
|
|
100
|
+
console.warn(
|
|
101
|
+
'promotedProductListenerIOS: This listener is only available on iOS',
|
|
102
|
+
);
|
|
103
|
+
return {remove: () => {}};
|
|
106
104
|
}
|
|
107
105
|
return emitter.addListener(IapEvent.PromotedProductIOS, listener);
|
|
108
106
|
};
|
|
@@ -114,7 +112,7 @@ export function initConnection(): Promise<boolean> {
|
|
|
114
112
|
|
|
115
113
|
export const getProducts = async (skus: string[]): Promise<Product[]> => {
|
|
116
114
|
console.warn(
|
|
117
|
-
|
|
115
|
+
"`getProducts` is deprecated. Use `requestProducts({ skus, type: 'inapp' })` instead. This function will be removed in version 3.0.0.",
|
|
118
116
|
);
|
|
119
117
|
if (!skus?.length) {
|
|
120
118
|
return Promise.reject(new Error('"skus" is required'));
|
|
@@ -148,7 +146,7 @@ export const getSubscriptions = async (
|
|
|
148
146
|
skus: string[],
|
|
149
147
|
): Promise<SubscriptionProduct[]> => {
|
|
150
148
|
console.warn(
|
|
151
|
-
|
|
149
|
+
"`getSubscriptions` is deprecated. Use `requestProducts({ skus, type: 'subs' })` instead. This function will be removed in version 3.0.0.",
|
|
152
150
|
);
|
|
153
151
|
if (!skus?.length) {
|
|
154
152
|
return Promise.reject(new Error('"skus" is required'));
|
|
@@ -272,7 +270,7 @@ export const getPurchaseHistory = ({
|
|
|
272
270
|
onlyIncludeActiveItems?: boolean;
|
|
273
271
|
} = {}): Promise<ProductPurchase[]> => {
|
|
274
272
|
console.warn(
|
|
275
|
-
|
|
273
|
+
'`getPurchaseHistory` is deprecated. Use `getPurchaseHistories` instead. This function will be removed in version 3.0.0.',
|
|
276
274
|
);
|
|
277
275
|
return getPurchaseHistories({
|
|
278
276
|
alsoPublishToEventListener,
|
|
@@ -322,9 +320,8 @@ export const getAvailablePurchases = ({
|
|
|
322
320
|
),
|
|
323
321
|
android: async () => {
|
|
324
322
|
const products = await ExpoIapModule.getAvailableItemsByType('inapp');
|
|
325
|
-
const subscriptions =
|
|
326
|
-
'subs'
|
|
327
|
-
);
|
|
323
|
+
const subscriptions =
|
|
324
|
+
await ExpoIapModule.getAvailableItemsByType('subs');
|
|
328
325
|
return products.concat(subscriptions);
|
|
329
326
|
},
|
|
330
327
|
}) || (() => Promise.resolve([]))
|
|
@@ -343,7 +340,6 @@ const offerToRecordIos = (
|
|
|
343
340
|
};
|
|
344
341
|
};
|
|
345
342
|
|
|
346
|
-
|
|
347
343
|
// Define discriminated union with explicit type parameter
|
|
348
344
|
// Using legacy types internally for backward compatibility
|
|
349
345
|
type PurchaseRequest =
|
|
@@ -373,7 +369,8 @@ const normalizeRequestProps = (
|
|
|
373
369
|
if (platform === 'ios') {
|
|
374
370
|
return {
|
|
375
371
|
sku: request.sku || (request.skus?.[0] ?? ''),
|
|
376
|
-
andDangerouslyFinishTransactionAutomaticallyIOS:
|
|
372
|
+
andDangerouslyFinishTransactionAutomaticallyIOS:
|
|
373
|
+
request.andDangerouslyFinishTransactionAutomaticallyIOS,
|
|
377
374
|
appAccountToken: request.appAccountToken,
|
|
378
375
|
quantity: request.quantity,
|
|
379
376
|
withOffer: request.withOffer,
|
|
@@ -385,7 +382,7 @@ const normalizeRequestProps = (
|
|
|
385
382
|
obfuscatedProfileIdAndroid: request.obfuscatedProfileIdAndroid,
|
|
386
383
|
isOfferPersonalized: request.isOfferPersonalized,
|
|
387
384
|
};
|
|
388
|
-
|
|
385
|
+
|
|
389
386
|
// Add subscription-specific fields if present
|
|
390
387
|
if ('subscriptionOffers' in request && request.subscriptionOffers) {
|
|
391
388
|
androidRequest.subscriptionOffers = request.subscriptionOffers;
|
|
@@ -396,7 +393,7 @@ const normalizeRequestProps = (
|
|
|
396
393
|
if ('replacementModeAndroid' in request) {
|
|
397
394
|
androidRequest.replacementModeAndroid = request.replacementModeAndroid;
|
|
398
395
|
}
|
|
399
|
-
|
|
396
|
+
|
|
400
397
|
return androidRequest;
|
|
401
398
|
}
|
|
402
399
|
}
|
|
@@ -407,11 +404,11 @@ const normalizeRequestProps = (
|
|
|
407
404
|
|
|
408
405
|
/**
|
|
409
406
|
* Request a purchase for products or subscriptions.
|
|
410
|
-
*
|
|
407
|
+
*
|
|
411
408
|
* @param requestObj - Purchase request configuration
|
|
412
409
|
* @param requestObj.request - Platform-specific purchase parameters
|
|
413
410
|
* @param requestObj.type - Type of purchase: 'inapp' for products (default) or 'subs' for subscriptions
|
|
414
|
-
*
|
|
411
|
+
*
|
|
415
412
|
* @example
|
|
416
413
|
* ```typescript
|
|
417
414
|
* // Product purchase
|
|
@@ -422,12 +419,12 @@ const normalizeRequestProps = (
|
|
|
422
419
|
* },
|
|
423
420
|
* type: 'inapp'
|
|
424
421
|
* });
|
|
425
|
-
*
|
|
422
|
+
*
|
|
426
423
|
* // Subscription purchase
|
|
427
424
|
* await requestPurchase({
|
|
428
425
|
* request: {
|
|
429
426
|
* ios: { sku: subscriptionId },
|
|
430
|
-
* android: {
|
|
427
|
+
* android: {
|
|
431
428
|
* skus: [subscriptionId],
|
|
432
429
|
* subscriptionOffers: [{ sku: subscriptionId, offerToken: 'token' }]
|
|
433
430
|
* }
|
|
@@ -449,7 +446,7 @@ export const requestPurchase = (
|
|
|
449
446
|
|
|
450
447
|
if (Platform.OS === 'ios') {
|
|
451
448
|
const normalizedRequest = normalizeRequestProps(request, 'ios');
|
|
452
|
-
|
|
449
|
+
|
|
453
450
|
if (!normalizedRequest?.sku) {
|
|
454
451
|
throw new Error(
|
|
455
452
|
'Invalid request for iOS. The `sku` property is required and must be a string.',
|
|
@@ -482,7 +479,7 @@ export const requestPurchase = (
|
|
|
482
479
|
|
|
483
480
|
if (Platform.OS === 'android') {
|
|
484
481
|
const normalizedRequest = normalizeRequestProps(request, 'android');
|
|
485
|
-
|
|
482
|
+
|
|
486
483
|
if (!normalizedRequest?.skus?.length) {
|
|
487
484
|
throw new Error(
|
|
488
485
|
'Invalid request for Android. The `skus` property is required and must be a non-empty array.',
|
|
@@ -546,7 +543,7 @@ export const requestPurchase = (
|
|
|
546
543
|
|
|
547
544
|
/**
|
|
548
545
|
* @deprecated Use `requestPurchase({ request, type: 'subs' })` instead. This method will be removed in version 3.0.0.
|
|
549
|
-
*
|
|
546
|
+
*
|
|
550
547
|
* @example
|
|
551
548
|
* ```typescript
|
|
552
549
|
* // Old way (deprecated)
|
|
@@ -555,12 +552,12 @@ export const requestPurchase = (
|
|
|
555
552
|
* // or for Android
|
|
556
553
|
* skus: [subscriptionId],
|
|
557
554
|
* });
|
|
558
|
-
*
|
|
555
|
+
*
|
|
559
556
|
* // New way (recommended)
|
|
560
557
|
* await requestPurchase({
|
|
561
558
|
* request: {
|
|
562
559
|
* ios: { sku: subscriptionId },
|
|
563
|
-
* android: {
|
|
560
|
+
* android: {
|
|
564
561
|
* skus: [subscriptionId],
|
|
565
562
|
* subscriptionOffers: [{ sku: subscriptionId, offerToken: 'token' }]
|
|
566
563
|
* }
|
|
@@ -584,7 +581,7 @@ export const requestSubscription = async (
|
|
|
584
581
|
|
|
585
582
|
export const finishTransaction = ({
|
|
586
583
|
purchase,
|
|
587
|
-
isConsumable,
|
|
584
|
+
isConsumable = false,
|
|
588
585
|
}: {
|
|
589
586
|
purchase: Purchase;
|
|
590
587
|
isConsumable?: boolean;
|
|
@@ -625,16 +622,16 @@ export const finishTransaction = ({
|
|
|
625
622
|
|
|
626
623
|
/**
|
|
627
624
|
* Retrieves the current storefront information from iOS App Store
|
|
628
|
-
*
|
|
625
|
+
*
|
|
629
626
|
* @returns Promise resolving to the storefront country code
|
|
630
627
|
* @throws Error if called on non-iOS platform
|
|
631
|
-
*
|
|
628
|
+
*
|
|
632
629
|
* @example
|
|
633
630
|
* ```typescript
|
|
634
631
|
* const storefront = await getStorefrontIOS();
|
|
635
632
|
* console.log(storefront); // 'US'
|
|
636
633
|
* ```
|
|
637
|
-
*
|
|
634
|
+
*
|
|
638
635
|
* @platform iOS
|
|
639
636
|
*/
|
|
640
637
|
export const getStorefrontIOS = (): Promise<string> => {
|
|
@@ -655,5 +652,47 @@ export const getStorefront = (): Promise<string> => {
|
|
|
655
652
|
return getStorefrontIOS();
|
|
656
653
|
};
|
|
657
654
|
|
|
655
|
+
/**
|
|
656
|
+
* Internal receipt validation function (NOT RECOMMENDED for production use)
|
|
657
|
+
*
|
|
658
|
+
* WARNING: This function performs client-side validation which is NOT secure.
|
|
659
|
+
* For production apps, always validate receipts on your secure server:
|
|
660
|
+
* - iOS: Send receipt data to Apple's verification endpoint from your server
|
|
661
|
+
* - Android: Use Google Play Developer API with service account credentials
|
|
662
|
+
*/
|
|
663
|
+
export const validateReceipt = async (
|
|
664
|
+
sku: string,
|
|
665
|
+
androidOptions?: {
|
|
666
|
+
packageName: string;
|
|
667
|
+
productToken: string;
|
|
668
|
+
accessToken: string;
|
|
669
|
+
isSub?: boolean;
|
|
670
|
+
},
|
|
671
|
+
): Promise<any> => {
|
|
672
|
+
if (Platform.OS === 'ios') {
|
|
673
|
+
return await validateReceiptIOS(sku);
|
|
674
|
+
} else if (Platform.OS === 'android') {
|
|
675
|
+
if (
|
|
676
|
+
!androidOptions ||
|
|
677
|
+
!androidOptions.packageName ||
|
|
678
|
+
!androidOptions.productToken ||
|
|
679
|
+
!androidOptions.accessToken
|
|
680
|
+
) {
|
|
681
|
+
throw new Error(
|
|
682
|
+
'Android validation requires packageName, productToken, and accessToken',
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
return await validateReceiptAndroid({
|
|
686
|
+
packageName: androidOptions.packageName,
|
|
687
|
+
productId: sku,
|
|
688
|
+
productToken: androidOptions.productToken,
|
|
689
|
+
accessToken: androidOptions.accessToken,
|
|
690
|
+
isSub: androidOptions.isSub,
|
|
691
|
+
});
|
|
692
|
+
} else {
|
|
693
|
+
throw new Error('Platform not supported');
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
|
|
658
697
|
export * from './useIap';
|
|
659
698
|
export * from './utils/errorMapping';
|
package/src/modules/android.ts
CHANGED
|
@@ -102,11 +102,9 @@ export const acknowledgePurchaseAndroid = ({
|
|
|
102
102
|
* Open the Google Play Store to redeem offer codes (Android only).
|
|
103
103
|
* Note: Google Play does not provide a direct API to redeem codes within the app.
|
|
104
104
|
* This function opens the Play Store where users can manually enter their codes.
|
|
105
|
-
*
|
|
105
|
+
*
|
|
106
106
|
* @returns {Promise<void>}
|
|
107
107
|
*/
|
|
108
108
|
export const openRedeemOfferCodeAndroid = async (): Promise<void> => {
|
|
109
|
-
return Linking.openURL(
|
|
110
|
-
`https://play.google.com/redeem?code=`
|
|
111
|
-
);
|
|
109
|
+
return Linking.openURL(`https://play.google.com/redeem?code=`);
|
|
112
110
|
};
|
package/src/modules/ios.ts
CHANGED
|
@@ -11,7 +11,10 @@ import {
|
|
|
11
11
|
Purchase,
|
|
12
12
|
SubscriptionPurchase,
|
|
13
13
|
} from '../ExpoIap.types';
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
ProductStatusIos,
|
|
16
|
+
AppTransactionIOS,
|
|
17
|
+
} from '../types/ExpoIapIos.types';
|
|
15
18
|
|
|
16
19
|
export type TransactionEvent = {
|
|
17
20
|
transaction?: ProductPurchase;
|
|
@@ -35,7 +38,6 @@ export type TransactionEvent = {
|
|
|
35
38
|
export const transactionUpdatedIos = (
|
|
36
39
|
listener: (event: TransactionEvent) => void,
|
|
37
40
|
) => {
|
|
38
|
-
|
|
39
41
|
const isProductPurchase = (item: unknown): item is ProductPurchase => {
|
|
40
42
|
return (
|
|
41
43
|
item != null &&
|
|
@@ -86,10 +88,10 @@ export function isProductIos<T extends {platform?: string}>(
|
|
|
86
88
|
/**
|
|
87
89
|
* Sync state with Appstore (iOS only)
|
|
88
90
|
* https://developer.apple.com/documentation/storekit/appstore/3791906-sync
|
|
89
|
-
*
|
|
91
|
+
*
|
|
90
92
|
* @returns Promise resolving to null on success
|
|
91
93
|
* @throws Error if called on non-iOS platform
|
|
92
|
-
*
|
|
94
|
+
*
|
|
93
95
|
* @platform iOS
|
|
94
96
|
*/
|
|
95
97
|
export const syncIOS = (): Promise<null> => {
|
|
@@ -98,50 +100,56 @@ export const syncIOS = (): Promise<null> => {
|
|
|
98
100
|
|
|
99
101
|
/**
|
|
100
102
|
* Check if user is eligible for introductory offer
|
|
101
|
-
*
|
|
103
|
+
*
|
|
102
104
|
* @param groupID The subscription group ID
|
|
103
105
|
* @returns Promise resolving to true if eligible
|
|
104
106
|
* @throws Error if called on non-iOS platform
|
|
105
|
-
*
|
|
107
|
+
*
|
|
106
108
|
* @platform iOS
|
|
107
109
|
*/
|
|
108
|
-
export const isEligibleForIntroOfferIOS = (
|
|
110
|
+
export const isEligibleForIntroOfferIOS = (
|
|
111
|
+
groupID: string,
|
|
112
|
+
): Promise<boolean> => {
|
|
109
113
|
return ExpoIapModule.isEligibleForIntroOffer(groupID);
|
|
110
114
|
};
|
|
111
115
|
|
|
112
116
|
/**
|
|
113
117
|
* Get subscription status for a specific SKU
|
|
114
|
-
*
|
|
118
|
+
*
|
|
115
119
|
* @param sku The product SKU
|
|
116
120
|
* @returns Promise resolving to array of subscription status
|
|
117
121
|
* @throws Error if called on non-iOS platform
|
|
118
|
-
*
|
|
122
|
+
*
|
|
119
123
|
* @platform iOS
|
|
120
124
|
*/
|
|
121
|
-
export const subscriptionStatusIOS = (
|
|
125
|
+
export const subscriptionStatusIOS = (
|
|
126
|
+
sku: string,
|
|
127
|
+
): Promise<ProductStatusIos[]> => {
|
|
122
128
|
return ExpoIapModule.subscriptionStatus(sku);
|
|
123
129
|
};
|
|
124
130
|
|
|
125
131
|
/**
|
|
126
132
|
* Get current entitlement for a specific SKU
|
|
127
|
-
*
|
|
133
|
+
*
|
|
128
134
|
* @param sku The product SKU
|
|
129
135
|
* @returns Promise resolving to current entitlement
|
|
130
136
|
* @throws Error if called on non-iOS platform
|
|
131
|
-
*
|
|
137
|
+
*
|
|
132
138
|
* @platform iOS
|
|
133
139
|
*/
|
|
134
|
-
export const currentEntitlementIOS = (
|
|
140
|
+
export const currentEntitlementIOS = (
|
|
141
|
+
sku: string,
|
|
142
|
+
): Promise<ProductPurchase> => {
|
|
135
143
|
return ExpoIapModule.currentEntitlement(sku);
|
|
136
144
|
};
|
|
137
145
|
|
|
138
146
|
/**
|
|
139
147
|
* Get latest transaction for a specific SKU
|
|
140
|
-
*
|
|
148
|
+
*
|
|
141
149
|
* @param sku The product SKU
|
|
142
150
|
* @returns Promise resolving to latest transaction
|
|
143
151
|
* @throws Error if called on non-iOS platform
|
|
144
|
-
*
|
|
152
|
+
*
|
|
145
153
|
* @platform iOS
|
|
146
154
|
*/
|
|
147
155
|
export const latestTransactionIOS = (sku: string): Promise<ProductPurchase> => {
|
|
@@ -150,15 +158,17 @@ export const latestTransactionIOS = (sku: string): Promise<ProductPurchase> => {
|
|
|
150
158
|
|
|
151
159
|
/**
|
|
152
160
|
* Begin refund request for a specific SKU
|
|
153
|
-
*
|
|
161
|
+
*
|
|
154
162
|
* @param sku The product SKU
|
|
155
163
|
* @returns Promise resolving to refund request status
|
|
156
164
|
* @throws Error if called on non-iOS platform
|
|
157
|
-
*
|
|
165
|
+
*
|
|
158
166
|
* @platform iOS
|
|
159
167
|
*/
|
|
160
168
|
type RefundRequestStatus = 'success' | 'userCancelled';
|
|
161
|
-
export const beginRefundRequestIOS = (
|
|
169
|
+
export const beginRefundRequestIOS = (
|
|
170
|
+
sku: string,
|
|
171
|
+
): Promise<RefundRequestStatus> => {
|
|
162
172
|
return ExpoIapModule.beginRefundRequest(sku);
|
|
163
173
|
};
|
|
164
174
|
|
|
@@ -166,10 +176,10 @@ export const beginRefundRequestIOS = (sku: string): Promise<RefundRequestStatus>
|
|
|
166
176
|
* Shows the system UI for managing subscriptions.
|
|
167
177
|
* When the user changes subscription renewal status, the system will emit events to
|
|
168
178
|
* purchaseUpdatedListener and transactionUpdatedIos listeners.
|
|
169
|
-
*
|
|
179
|
+
*
|
|
170
180
|
* @returns Promise resolving to null on success
|
|
171
181
|
* @throws Error if called on non-iOS platform
|
|
172
|
-
*
|
|
182
|
+
*
|
|
173
183
|
* @platform iOS
|
|
174
184
|
*/
|
|
175
185
|
export const showManageSubscriptionsIOS = (): Promise<null> => {
|
|
@@ -197,7 +207,7 @@ export const getReceiptIOS = (): Promise<string> => {
|
|
|
197
207
|
* @param sku The product's SKU (on iOS)
|
|
198
208
|
* @returns Promise resolving to true if the transaction is verified
|
|
199
209
|
* @throws Error if called on non-iOS platform
|
|
200
|
-
*
|
|
210
|
+
*
|
|
201
211
|
* @platform iOS
|
|
202
212
|
*/
|
|
203
213
|
export const isTransactionVerifiedIOS = (sku: string): Promise<boolean> => {
|
|
@@ -211,7 +221,7 @@ export const isTransactionVerifiedIOS = (sku: string): Promise<boolean> => {
|
|
|
211
221
|
* @param sku The product's SKU (on iOS)
|
|
212
222
|
* @returns Promise resolving to JWS representation of the transaction
|
|
213
223
|
* @throws Error if called on non-iOS platform
|
|
214
|
-
*
|
|
224
|
+
*
|
|
215
225
|
* @platform iOS
|
|
216
226
|
*/
|
|
217
227
|
export const getTransactionJwsIOS = (sku: string): Promise<string> => {
|
|
@@ -248,12 +258,12 @@ export const validateReceiptIOS = async (
|
|
|
248
258
|
/**
|
|
249
259
|
* Present the code redemption sheet for offer codes (iOS only).
|
|
250
260
|
* This allows users to redeem promotional codes for in-app purchases and subscriptions.
|
|
251
|
-
*
|
|
261
|
+
*
|
|
252
262
|
* Note: This only works on real devices, not simulators.
|
|
253
|
-
*
|
|
263
|
+
*
|
|
254
264
|
* @returns Promise resolving to true if the sheet was presented successfully
|
|
255
265
|
* @throws Error if called on non-iOS platform or tvOS
|
|
256
|
-
*
|
|
266
|
+
*
|
|
257
267
|
* @platform iOS
|
|
258
268
|
*/
|
|
259
269
|
export const presentCodeRedemptionSheetIOS = (): Promise<boolean> => {
|
|
@@ -263,14 +273,14 @@ export const presentCodeRedemptionSheetIOS = (): Promise<boolean> => {
|
|
|
263
273
|
/**
|
|
264
274
|
* Get app transaction information (iOS 16.0+).
|
|
265
275
|
* AppTransaction represents the initial purchase that unlocked the app.
|
|
266
|
-
*
|
|
276
|
+
*
|
|
267
277
|
* NOTE: This function requires:
|
|
268
278
|
* - iOS 16.0 or later at runtime
|
|
269
279
|
* - Xcode 15.0+ with iOS 16.0 SDK for compilation
|
|
270
|
-
*
|
|
280
|
+
*
|
|
271
281
|
* @returns Promise resolving to the app transaction information or null if not available
|
|
272
282
|
* @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK
|
|
273
|
-
*
|
|
283
|
+
*
|
|
274
284
|
* @platform iOS
|
|
275
285
|
* @since iOS 16.0
|
|
276
286
|
*/
|
|
@@ -281,10 +291,10 @@ export const getAppTransactionIOS = (): Promise<AppTransactionIOS | null> => {
|
|
|
281
291
|
/**
|
|
282
292
|
* Get the promoted product details (iOS only).
|
|
283
293
|
* This is called after a promoted product event is received from the App Store.
|
|
284
|
-
*
|
|
294
|
+
*
|
|
285
295
|
* @returns Promise resolving to the promoted product details or null if none available
|
|
286
296
|
* @throws Error if called on non-iOS platform
|
|
287
|
-
*
|
|
297
|
+
*
|
|
288
298
|
* @platform iOS
|
|
289
299
|
*/
|
|
290
300
|
export const getPromotedProductIOS = (): Promise<any | null> => {
|
|
@@ -294,10 +304,10 @@ export const getPromotedProductIOS = (): Promise<any | null> => {
|
|
|
294
304
|
/**
|
|
295
305
|
* Complete the purchase of a promoted product (iOS only).
|
|
296
306
|
* This should be called after showing your purchase UI for a promoted product.
|
|
297
|
-
*
|
|
307
|
+
*
|
|
298
308
|
* @returns Promise resolving when the purchase is initiated
|
|
299
309
|
* @throws Error if called on non-iOS platform or no promoted product is available
|
|
300
|
-
*
|
|
310
|
+
*
|
|
301
311
|
* @platform iOS
|
|
302
312
|
*/
|
|
303
313
|
export const buyPromotedProductIOS = (): Promise<void> => {
|
|
@@ -311,7 +321,9 @@ export const buyPromotedProductIOS = (): Promise<void> => {
|
|
|
311
321
|
* @deprecated Use `syncIOS` instead. This function will be removed in version 3.0.0.
|
|
312
322
|
*/
|
|
313
323
|
export const sync = (): Promise<null> => {
|
|
314
|
-
console.warn(
|
|
324
|
+
console.warn(
|
|
325
|
+
'`sync` is deprecated. Use `syncIOS` instead. This function will be removed in version 3.0.0.',
|
|
326
|
+
);
|
|
315
327
|
return syncIOS();
|
|
316
328
|
};
|
|
317
329
|
|
|
@@ -319,15 +331,21 @@ export const sync = (): Promise<null> => {
|
|
|
319
331
|
* @deprecated Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.
|
|
320
332
|
*/
|
|
321
333
|
export const isEligibleForIntroOffer = (groupID: string): Promise<boolean> => {
|
|
322
|
-
console.warn(
|
|
334
|
+
console.warn(
|
|
335
|
+
'`isEligibleForIntroOffer` is deprecated. Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.',
|
|
336
|
+
);
|
|
323
337
|
return isEligibleForIntroOfferIOS(groupID);
|
|
324
338
|
};
|
|
325
339
|
|
|
326
340
|
/**
|
|
327
341
|
* @deprecated Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.
|
|
328
342
|
*/
|
|
329
|
-
export const subscriptionStatus = (
|
|
330
|
-
|
|
343
|
+
export const subscriptionStatus = (
|
|
344
|
+
sku: string,
|
|
345
|
+
): Promise<ProductStatusIos[]> => {
|
|
346
|
+
console.warn(
|
|
347
|
+
'`subscriptionStatus` is deprecated. Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.',
|
|
348
|
+
);
|
|
331
349
|
return subscriptionStatusIOS(sku);
|
|
332
350
|
};
|
|
333
351
|
|
|
@@ -335,7 +353,9 @@ export const subscriptionStatus = (sku: string): Promise<ProductStatusIos[]> =>
|
|
|
335
353
|
* @deprecated Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.
|
|
336
354
|
*/
|
|
337
355
|
export const currentEntitlement = (sku: string): Promise<ProductPurchase> => {
|
|
338
|
-
console.warn(
|
|
356
|
+
console.warn(
|
|
357
|
+
'`currentEntitlement` is deprecated. Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.',
|
|
358
|
+
);
|
|
339
359
|
return currentEntitlementIOS(sku);
|
|
340
360
|
};
|
|
341
361
|
|
|
@@ -343,15 +363,21 @@ export const currentEntitlement = (sku: string): Promise<ProductPurchase> => {
|
|
|
343
363
|
* @deprecated Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.
|
|
344
364
|
*/
|
|
345
365
|
export const latestTransaction = (sku: string): Promise<ProductPurchase> => {
|
|
346
|
-
console.warn(
|
|
366
|
+
console.warn(
|
|
367
|
+
'`latestTransaction` is deprecated. Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.',
|
|
368
|
+
);
|
|
347
369
|
return latestTransactionIOS(sku);
|
|
348
370
|
};
|
|
349
371
|
|
|
350
372
|
/**
|
|
351
373
|
* @deprecated Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.
|
|
352
374
|
*/
|
|
353
|
-
export const beginRefundRequest = (
|
|
354
|
-
|
|
375
|
+
export const beginRefundRequest = (
|
|
376
|
+
sku: string,
|
|
377
|
+
): Promise<RefundRequestStatus> => {
|
|
378
|
+
console.warn(
|
|
379
|
+
'`beginRefundRequest` is deprecated. Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.',
|
|
380
|
+
);
|
|
355
381
|
return beginRefundRequestIOS(sku);
|
|
356
382
|
};
|
|
357
383
|
|
|
@@ -359,7 +385,9 @@ export const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>
|
|
|
359
385
|
* @deprecated Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.
|
|
360
386
|
*/
|
|
361
387
|
export const showManageSubscriptions = (): Promise<null> => {
|
|
362
|
-
console.warn(
|
|
388
|
+
console.warn(
|
|
389
|
+
'`showManageSubscriptions` is deprecated. Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.',
|
|
390
|
+
);
|
|
363
391
|
return showManageSubscriptionsIOS();
|
|
364
392
|
};
|
|
365
393
|
|
|
@@ -367,7 +395,9 @@ export const showManageSubscriptions = (): Promise<null> => {
|
|
|
367
395
|
* @deprecated Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.
|
|
368
396
|
*/
|
|
369
397
|
export const getReceiptIos = (): Promise<string> => {
|
|
370
|
-
console.warn(
|
|
398
|
+
console.warn(
|
|
399
|
+
'`getReceiptIos` is deprecated. Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.',
|
|
400
|
+
);
|
|
371
401
|
return getReceiptIOS();
|
|
372
402
|
};
|
|
373
403
|
|
|
@@ -375,7 +405,9 @@ export const getReceiptIos = (): Promise<string> => {
|
|
|
375
405
|
* @deprecated Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.
|
|
376
406
|
*/
|
|
377
407
|
export const isTransactionVerified = (sku: string): Promise<boolean> => {
|
|
378
|
-
console.warn(
|
|
408
|
+
console.warn(
|
|
409
|
+
'`isTransactionVerified` is deprecated. Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.',
|
|
410
|
+
);
|
|
379
411
|
return isTransactionVerifiedIOS(sku);
|
|
380
412
|
};
|
|
381
413
|
|
|
@@ -383,7 +415,9 @@ export const isTransactionVerified = (sku: string): Promise<boolean> => {
|
|
|
383
415
|
* @deprecated Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.
|
|
384
416
|
*/
|
|
385
417
|
export const getTransactionJws = (sku: string): Promise<string> => {
|
|
386
|
-
console.warn(
|
|
418
|
+
console.warn(
|
|
419
|
+
'`getTransactionJws` is deprecated. Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.',
|
|
420
|
+
);
|
|
387
421
|
return getTransactionJwsIOS(sku);
|
|
388
422
|
};
|
|
389
423
|
|
|
@@ -398,7 +432,9 @@ export const validateReceiptIos = async (
|
|
|
398
432
|
jwsRepresentation: string;
|
|
399
433
|
latestTransaction?: ProductPurchase;
|
|
400
434
|
}> => {
|
|
401
|
-
console.warn(
|
|
435
|
+
console.warn(
|
|
436
|
+
'`validateReceiptIos` is deprecated. Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.',
|
|
437
|
+
);
|
|
402
438
|
return validateReceiptIOS(sku);
|
|
403
439
|
};
|
|
404
440
|
|
|
@@ -406,7 +442,9 @@ export const validateReceiptIos = async (
|
|
|
406
442
|
* @deprecated Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.
|
|
407
443
|
*/
|
|
408
444
|
export const presentCodeRedemptionSheet = (): Promise<boolean> => {
|
|
409
|
-
console.warn(
|
|
445
|
+
console.warn(
|
|
446
|
+
'`presentCodeRedemptionSheet` is deprecated. Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.',
|
|
447
|
+
);
|
|
410
448
|
return presentCodeRedemptionSheetIOS();
|
|
411
449
|
};
|
|
412
450
|
|
|
@@ -414,6 +452,8 @@ export const presentCodeRedemptionSheet = (): Promise<boolean> => {
|
|
|
414
452
|
* @deprecated Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.
|
|
415
453
|
*/
|
|
416
454
|
export const getAppTransaction = (): Promise<AppTransactionIOS | null> => {
|
|
417
|
-
console.warn(
|
|
455
|
+
console.warn(
|
|
456
|
+
'`getAppTransaction` is deprecated. Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.',
|
|
457
|
+
);
|
|
418
458
|
return getAppTransactionIOS();
|
|
419
459
|
};
|