expo-iap 2.8.7 → 2.9.0-rc.2
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/CHANGELOG.md +28 -0
- package/CLAUDE.md +7 -0
- package/CONTRIBUTING.md +3 -4
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +7 -7
- package/android/src/main/java/expo/modules/iap/Types.kt +1 -1
- package/build/ExpoIap.types.d.ts +4 -4
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js +3 -0
- package/build/ExpoIap.types.js.map +1 -1
- package/build/helpers/subscription.d.ts.map +1 -1
- package/build/helpers/subscription.js +3 -6
- package/build/helpers/subscription.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +14 -12
- 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/types/ExpoIapAndroid.types.d.ts +2 -2
- package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
- package/build/types/ExpoIapAndroid.types.js.map +1 -1
- package/build/types/ExpoIapIOS.types.d.ts +3 -3
- package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
- package/build/types/ExpoIapIOS.types.js.map +1 -1
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js.map +1 -1
- package/ios/ExpoIap.podspec +1 -0
- package/ios/ExpoIapModule.swift +353 -1180
- package/jest.config.js +14 -17
- package/package.json +5 -3
- package/plugin/build/withIAP.d.ts +7 -1
- package/plugin/build/withIAP.js +16 -2
- package/plugin/build/withLocalOpenIAP.d.ts +9 -0
- package/plugin/build/withLocalOpenIAP.js +85 -0
- package/plugin/src/withIAP.ts +21 -2
- package/plugin/src/withLocalOpenIAP.ts +66 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/ExpoIap.types.ts +5 -11
- package/src/helpers/subscription.ts +21 -28
- package/src/index.ts +27 -25
- package/src/modules/android.ts +7 -7
- package/src/modules/ios.ts +11 -5
- package/src/types/ExpoIapAndroid.types.ts +3 -4
- package/src/types/ExpoIapIOS.types.ts +4 -3
- package/src/useIAP.ts +10 -4
package/src/modules/ios.ts
CHANGED
|
@@ -5,7 +5,11 @@ import {purchaseUpdatedListener} from '..';
|
|
|
5
5
|
import ExpoIapModule from '../ExpoIapModule';
|
|
6
6
|
|
|
7
7
|
// Types
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Product,
|
|
10
|
+
Purchase,
|
|
11
|
+
PurchaseError,
|
|
12
|
+
} from '../ExpoIap.types';
|
|
9
13
|
import type {
|
|
10
14
|
ProductStatusIOS,
|
|
11
15
|
AppTransactionIOS,
|
|
@@ -133,7 +137,9 @@ export const subscriptionStatusIOS = (
|
|
|
133
137
|
*
|
|
134
138
|
* @platform iOS
|
|
135
139
|
*/
|
|
136
|
-
export const currentEntitlementIOS = (
|
|
140
|
+
export const currentEntitlementIOS = (
|
|
141
|
+
sku: string,
|
|
142
|
+
): Promise<Purchase> => {
|
|
137
143
|
return ExpoIapModule.currentEntitlementIOS(sku);
|
|
138
144
|
};
|
|
139
145
|
|
|
@@ -318,7 +324,7 @@ export const buyPromotedProductIOS = (): Promise<void> => {
|
|
|
318
324
|
|
|
319
325
|
/**
|
|
320
326
|
* Get pending transactions that haven't been finished yet (iOS only).
|
|
321
|
-
*
|
|
327
|
+
*
|
|
322
328
|
* @returns Promise resolving to array of pending transactions
|
|
323
329
|
* @platform iOS
|
|
324
330
|
*/
|
|
@@ -328,9 +334,9 @@ export const getPendingTransactionsIOS = (): Promise<any[]> => {
|
|
|
328
334
|
|
|
329
335
|
/**
|
|
330
336
|
* Clear a specific transaction (iOS only).
|
|
331
|
-
*
|
|
337
|
+
*
|
|
332
338
|
* @returns Promise resolving when transaction is cleared
|
|
333
|
-
* @platform iOS
|
|
339
|
+
* @platform iOS
|
|
334
340
|
*/
|
|
335
341
|
export const clearTransactionIOS = (): Promise<void> => {
|
|
336
342
|
return ExpoIapModule.clearTransactionIOS();
|
|
@@ -31,7 +31,7 @@ type ProductSubscriptionAndroidOfferDetail = {
|
|
|
31
31
|
export type ProductAndroid = ProductCommon & {
|
|
32
32
|
nameAndroid: string;
|
|
33
33
|
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail;
|
|
34
|
-
platform:
|
|
34
|
+
platform: "android";
|
|
35
35
|
subscriptionOfferDetailsAndroid?: ProductSubscriptionAndroidOfferDetail[];
|
|
36
36
|
/**
|
|
37
37
|
* @deprecated Use `nameAndroid` instead. This field will be removed in v2.9.0.
|
|
@@ -144,7 +144,7 @@ export const PurchaseStateAndroid = PurchaseAndroidState;
|
|
|
144
144
|
|
|
145
145
|
// Legacy naming for backward compatibility
|
|
146
146
|
export type ProductPurchaseAndroid = PurchaseCommon & {
|
|
147
|
-
platform:
|
|
147
|
+
platform: "android";
|
|
148
148
|
/**
|
|
149
149
|
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
150
150
|
*/
|
|
@@ -167,8 +167,7 @@ export type PurchaseAndroid = ProductPurchaseAndroid;
|
|
|
167
167
|
/**
|
|
168
168
|
* @deprecated Use `ProductAndroidOneTimePurchaseOfferDetail` instead. This type will be removed in v2.9.0.
|
|
169
169
|
*/
|
|
170
|
-
export type OneTimePurchaseOfferDetails =
|
|
171
|
-
ProductAndroidOneTimePurchaseOfferDetail;
|
|
170
|
+
export type OneTimePurchaseOfferDetails = ProductAndroidOneTimePurchaseOfferDetail;
|
|
172
171
|
|
|
173
172
|
/**
|
|
174
173
|
* @deprecated Use `ProductSubscriptionAndroidOfferDetail` instead. This type will be removed in v2.9.0.
|
|
@@ -30,7 +30,7 @@ export type ProductIOS = ProductCommon & {
|
|
|
30
30
|
displayNameIOS: string;
|
|
31
31
|
isFamilyShareableIOS: boolean;
|
|
32
32
|
jsonRepresentationIOS: string;
|
|
33
|
-
platform:
|
|
33
|
+
platform: "ios";
|
|
34
34
|
subscriptionInfoIOS?: SubscriptionInfo;
|
|
35
35
|
/**
|
|
36
36
|
* @deprecated Use `displayNameIOS` instead. This field will be removed in v2.9.0.
|
|
@@ -69,7 +69,7 @@ export type ProductSubscriptionIOS = ProductIOS & {
|
|
|
69
69
|
introductoryPricePaymentModeIOS?: PaymentMode;
|
|
70
70
|
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
71
71
|
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
72
|
-
platform:
|
|
72
|
+
platform: "ios";
|
|
73
73
|
subscriptionPeriodNumberIOS?: string;
|
|
74
74
|
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
|
|
75
75
|
/**
|
|
@@ -140,7 +140,7 @@ export type ProductStatusIOS = {
|
|
|
140
140
|
// Legacy naming for backward compatibility
|
|
141
141
|
export type ProductPurchaseIOS = PurchaseCommon & {
|
|
142
142
|
// iOS basic fields
|
|
143
|
-
platform:
|
|
143
|
+
platform: "ios";
|
|
144
144
|
quantityIOS?: number;
|
|
145
145
|
originalTransactionDateIOS?: number;
|
|
146
146
|
originalTransactionIdentifierIOS?: string;
|
|
@@ -179,6 +179,7 @@ export type ProductPurchaseIOS = PurchaseCommon & {
|
|
|
179
179
|
// Preferred naming
|
|
180
180
|
export type PurchaseIOS = ProductPurchaseIOS;
|
|
181
181
|
|
|
182
|
+
|
|
182
183
|
export type AppTransactionIOS = {
|
|
183
184
|
appTransactionId?: string; // Only available in iOS 18.4+
|
|
184
185
|
originalPlatform?: string; // Only available in iOS 18.4+
|
package/src/useIAP.ts
CHANGED
|
@@ -107,7 +107,9 @@ type UseIap = {
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
export interface UseIAPOptions {
|
|
110
|
-
onPurchaseSuccess?: (
|
|
110
|
+
onPurchaseSuccess?: (
|
|
111
|
+
purchase: Purchase,
|
|
112
|
+
) => void;
|
|
111
113
|
onPurchaseError?: (error: PurchaseError) => void;
|
|
112
114
|
onSyncError?: (error: Error) => void;
|
|
113
115
|
shouldAutoSyncPurchases?: boolean; // New option to control auto-syncing
|
|
@@ -123,8 +125,12 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
123
125
|
const [products, setProducts] = useState<Product[]>([]);
|
|
124
126
|
const [promotedProductsIOS] = useState<Purchase[]>([]);
|
|
125
127
|
const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
|
|
126
|
-
const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>(
|
|
127
|
-
|
|
128
|
+
const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>(
|
|
129
|
+
[],
|
|
130
|
+
);
|
|
131
|
+
const [availablePurchases, setAvailablePurchases] = useState<
|
|
132
|
+
Purchase[]
|
|
133
|
+
>([]);
|
|
128
134
|
const [currentPurchase, setCurrentPurchase] = useState<Purchase>();
|
|
129
135
|
const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();
|
|
130
136
|
const [currentPurchaseError, setCurrentPurchaseError] =
|
|
@@ -255,7 +261,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
255
261
|
type?: 'inapp' | 'subs';
|
|
256
262
|
}): Promise<void> => {
|
|
257
263
|
console.warn(
|
|
258
|
-
"`requestProducts` is deprecated in useIAP hook. Use the new `fetchProducts` method instead. The 'request' prefix should only be used for event-based operations."
|
|
264
|
+
"`requestProducts` is deprecated in useIAP hook. Use the new `fetchProducts` method instead. The 'request' prefix should only be used for event-based operations."
|
|
259
265
|
);
|
|
260
266
|
return fetchProductsInternal(params);
|
|
261
267
|
},
|