expo-iap 2.6.2 → 2.7.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/android/build.gradle +9 -1
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +45 -44
- package/build/ExpoIap.types.d.ts +84 -2
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js +11 -2
- package/build/ExpoIap.types.js.map +1 -1
- package/build/index.d.ts +58 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +114 -12
- package/build/index.js.map +1 -1
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +0 -43
- package/build/modules/ios.js.map +1 -1
- package/build/types/ExpoIapIos.types.d.ts +1 -1
- package/build/types/ExpoIapIos.types.d.ts.map +1 -1
- package/build/types/ExpoIapIos.types.js.map +1 -1
- package/build/useIap.d.ts +2 -2
- package/build/useIap.d.ts.map +1 -1
- package/build/useIap.js.map +1 -1
- package/ios/ExpoIapModule.swift +9 -4
- package/package.json +1 -1
- package/src/ExpoIap.types.ts +125 -4
- package/src/index.ts +137 -31
- package/src/modules/ios.ts +0 -65
- package/src/types/ExpoIapIos.types.ts +1 -1
- package/src/useIap.ts +3 -1
package/src/modules/ios.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// External dependencies
|
|
2
|
-
import {Platform} from 'react-native';
|
|
3
2
|
|
|
4
3
|
// Internal modules
|
|
5
4
|
import {purchaseUpdatedListener} from '..';
|
|
@@ -39,10 +38,6 @@ export type TransactionEvent = {
|
|
|
39
38
|
export const transactionUpdatedIos = (
|
|
40
39
|
listener: (event: TransactionEvent) => void,
|
|
41
40
|
) => {
|
|
42
|
-
if (Platform.OS !== 'ios') {
|
|
43
|
-
throw new Error('This method is only available on iOS');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
const isProductPurchase = (item: unknown): item is ProductPurchase => {
|
|
47
42
|
return (
|
|
48
43
|
item != null &&
|
|
@@ -100,9 +95,6 @@ export function isProductIos<T extends {platform?: string}>(
|
|
|
100
95
|
* @platform iOS
|
|
101
96
|
*/
|
|
102
97
|
export const syncIOS = (): Promise<null> => {
|
|
103
|
-
if (Platform.OS !== 'ios') {
|
|
104
|
-
throw new Error('syncIOS: This method is only available on iOS');
|
|
105
|
-
}
|
|
106
98
|
return ExpoIapModule.sync();
|
|
107
99
|
};
|
|
108
100
|
|
|
@@ -118,11 +110,6 @@ export const syncIOS = (): Promise<null> => {
|
|
|
118
110
|
export const isEligibleForIntroOfferIOS = (
|
|
119
111
|
groupID: string,
|
|
120
112
|
): Promise<boolean> => {
|
|
121
|
-
if (Platform.OS !== 'ios') {
|
|
122
|
-
throw new Error(
|
|
123
|
-
'isEligibleForIntroOfferIOS: This method is only available on iOS',
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
113
|
return ExpoIapModule.isEligibleForIntroOffer(groupID);
|
|
127
114
|
};
|
|
128
115
|
|
|
@@ -138,11 +125,6 @@ export const isEligibleForIntroOfferIOS = (
|
|
|
138
125
|
export const subscriptionStatusIOS = (
|
|
139
126
|
sku: string,
|
|
140
127
|
): Promise<ProductStatusIos[]> => {
|
|
141
|
-
if (Platform.OS !== 'ios') {
|
|
142
|
-
throw new Error(
|
|
143
|
-
'subscriptionStatusIOS: This method is only available on iOS',
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
128
|
return ExpoIapModule.subscriptionStatus(sku);
|
|
147
129
|
};
|
|
148
130
|
|
|
@@ -158,11 +140,6 @@ export const subscriptionStatusIOS = (
|
|
|
158
140
|
export const currentEntitlementIOS = (
|
|
159
141
|
sku: string,
|
|
160
142
|
): Promise<ProductPurchase> => {
|
|
161
|
-
if (Platform.OS !== 'ios') {
|
|
162
|
-
throw new Error(
|
|
163
|
-
'currentEntitlementIOS: This method is only available on iOS',
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
143
|
return ExpoIapModule.currentEntitlement(sku);
|
|
167
144
|
};
|
|
168
145
|
|
|
@@ -176,11 +153,6 @@ export const currentEntitlementIOS = (
|
|
|
176
153
|
* @platform iOS
|
|
177
154
|
*/
|
|
178
155
|
export const latestTransactionIOS = (sku: string): Promise<ProductPurchase> => {
|
|
179
|
-
if (Platform.OS !== 'ios') {
|
|
180
|
-
throw new Error(
|
|
181
|
-
'latestTransactionIOS: This method is only available on iOS',
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
156
|
return ExpoIapModule.latestTransaction(sku);
|
|
185
157
|
};
|
|
186
158
|
|
|
@@ -197,11 +169,6 @@ type RefundRequestStatus = 'success' | 'userCancelled';
|
|
|
197
169
|
export const beginRefundRequestIOS = (
|
|
198
170
|
sku: string,
|
|
199
171
|
): Promise<RefundRequestStatus> => {
|
|
200
|
-
if (Platform.OS !== 'ios') {
|
|
201
|
-
throw new Error(
|
|
202
|
-
'beginRefundRequestIOS: This method is only available on iOS',
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
172
|
return ExpoIapModule.beginRefundRequest(sku);
|
|
206
173
|
};
|
|
207
174
|
|
|
@@ -216,11 +183,6 @@ export const beginRefundRequestIOS = (
|
|
|
216
183
|
* @platform iOS
|
|
217
184
|
*/
|
|
218
185
|
export const showManageSubscriptionsIOS = (): Promise<null> => {
|
|
219
|
-
if (Platform.OS !== 'ios') {
|
|
220
|
-
throw new Error(
|
|
221
|
-
'showManageSubscriptionsIOS: This method is only available on iOS',
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
186
|
return ExpoIapModule.showManageSubscriptions();
|
|
225
187
|
};
|
|
226
188
|
|
|
@@ -235,9 +197,6 @@ export const showManageSubscriptionsIOS = (): Promise<null> => {
|
|
|
235
197
|
* @returns {Promise<string>} Base64 encoded receipt data
|
|
236
198
|
*/
|
|
237
199
|
export const getReceiptIOS = (): Promise<string> => {
|
|
238
|
-
if (Platform.OS !== 'ios') {
|
|
239
|
-
throw new Error('This method is only available on iOS');
|
|
240
|
-
}
|
|
241
200
|
return ExpoIapModule.getReceiptData();
|
|
242
201
|
};
|
|
243
202
|
|
|
@@ -252,11 +211,6 @@ export const getReceiptIOS = (): Promise<string> => {
|
|
|
252
211
|
* @platform iOS
|
|
253
212
|
*/
|
|
254
213
|
export const isTransactionVerifiedIOS = (sku: string): Promise<boolean> => {
|
|
255
|
-
if (Platform.OS !== 'ios') {
|
|
256
|
-
throw new Error(
|
|
257
|
-
'isTransactionVerifiedIOS: This method is only available on iOS',
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
214
|
return ExpoIapModule.isTransactionVerified(sku);
|
|
261
215
|
};
|
|
262
216
|
|
|
@@ -271,11 +225,6 @@ export const isTransactionVerifiedIOS = (sku: string): Promise<boolean> => {
|
|
|
271
225
|
* @platform iOS
|
|
272
226
|
*/
|
|
273
227
|
export const getTransactionJwsIOS = (sku: string): Promise<string> => {
|
|
274
|
-
if (Platform.OS !== 'ios') {
|
|
275
|
-
throw new Error(
|
|
276
|
-
'getTransactionJwsIOS: This method is only available on iOS',
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
228
|
return ExpoIapModule.getTransactionJws(sku);
|
|
280
229
|
};
|
|
281
230
|
|
|
@@ -302,10 +251,6 @@ export const validateReceiptIOS = async (
|
|
|
302
251
|
jwsRepresentation: string;
|
|
303
252
|
latestTransaction?: ProductPurchase;
|
|
304
253
|
}> => {
|
|
305
|
-
if (Platform.OS !== 'ios') {
|
|
306
|
-
throw new Error('This method is only available on iOS');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
254
|
const result = await ExpoIapModule.validateReceiptIOS(sku);
|
|
310
255
|
return result;
|
|
311
256
|
};
|
|
@@ -322,11 +267,6 @@ export const validateReceiptIOS = async (
|
|
|
322
267
|
* @platform iOS
|
|
323
268
|
*/
|
|
324
269
|
export const presentCodeRedemptionSheetIOS = (): Promise<boolean> => {
|
|
325
|
-
if (Platform.OS !== 'ios') {
|
|
326
|
-
throw new Error(
|
|
327
|
-
'presentCodeRedemptionSheetIOS: This method is only available on iOS',
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
270
|
return ExpoIapModule.presentCodeRedemptionSheet();
|
|
331
271
|
};
|
|
332
272
|
|
|
@@ -340,11 +280,6 @@ export const presentCodeRedemptionSheetIOS = (): Promise<boolean> => {
|
|
|
340
280
|
* @platform iOS
|
|
341
281
|
*/
|
|
342
282
|
export const getAppTransactionIOS = (): Promise<AppTransactionIOS | null> => {
|
|
343
|
-
if (Platform.OS !== 'ios') {
|
|
344
|
-
throw new Error(
|
|
345
|
-
'getAppTransactionIOS: This method is only available on iOS',
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
283
|
return ExpoIapModule.getAppTransaction();
|
|
349
284
|
};
|
|
350
285
|
|
package/src/useIap.ts
CHANGED
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
PurchaseResult,
|
|
29
29
|
SubscriptionProduct,
|
|
30
30
|
SubscriptionPurchase,
|
|
31
|
+
RequestPurchaseProps,
|
|
32
|
+
RequestSubscriptionProps,
|
|
31
33
|
} from './ExpoIap.types';
|
|
32
34
|
|
|
33
35
|
type UseIap = {
|
|
@@ -53,7 +55,7 @@ type UseIap = {
|
|
|
53
55
|
getProducts: (skus: string[]) => Promise<void>;
|
|
54
56
|
getSubscriptions: (skus: string[]) => Promise<void>;
|
|
55
57
|
requestPurchase: (params: {
|
|
56
|
-
request:
|
|
58
|
+
request: RequestPurchaseProps | RequestSubscriptionProps;
|
|
57
59
|
type?: 'inapp' | 'subs';
|
|
58
60
|
}) => Promise<any>;
|
|
59
61
|
validateReceipt: (
|