expo-iap 2.7.7-rc.1 → 2.7.7

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.
@@ -11,7 +11,10 @@ import {
11
11
  Purchase,
12
12
  SubscriptionPurchase,
13
13
  } from '../ExpoIap.types';
14
- import type {ProductStatusIos, AppTransactionIOS} from '../types/ExpoIapIos.types';
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 = (groupID: string): Promise<boolean> => {
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 = (sku: string): Promise<ProductStatusIos[]> => {
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 = (sku: string): Promise<ProductPurchase> => {
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 = (sku: string): Promise<RefundRequestStatus> => {
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('`sync` is deprecated. Use `syncIOS` instead. This function will be removed in version 3.0.0.');
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('`isEligibleForIntroOffer` is deprecated. Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.');
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 = (sku: string): Promise<ProductStatusIos[]> => {
330
- console.warn('`subscriptionStatus` is deprecated. Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.');
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('`currentEntitlement` is deprecated. Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.');
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('`latestTransaction` is deprecated. Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.');
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 = (sku: string): Promise<RefundRequestStatus> => {
354
- console.warn('`beginRefundRequest` is deprecated. Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.');
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('`showManageSubscriptions` is deprecated. Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.');
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('`getReceiptIos` is deprecated. Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.');
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('`isTransactionVerified` is deprecated. Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.');
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('`getTransactionJws` is deprecated. Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.');
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('`validateReceiptIos` is deprecated. Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.');
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('`presentCodeRedemptionSheet` is deprecated. Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.');
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('`getAppTransaction` is deprecated. Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.');
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
  };
package/src/useIap.ts CHANGED
@@ -16,7 +16,12 @@ import {
16
16
  requestPurchase as requestPurchaseInternal,
17
17
  requestProducts,
18
18
  } from './';
19
- import {syncIOS, validateReceiptIOS, getPromotedProductIOS, buyPromotedProductIOS} from './modules/ios';
19
+ import {
20
+ syncIOS,
21
+ validateReceiptIOS,
22
+ getPromotedProductIOS,
23
+ buyPromotedProductIOS,
24
+ } from './modules/ios';
20
25
  import {validateReceiptAndroid} from './modules/android';
21
26
 
22
27
  // Types
@@ -58,9 +63,15 @@ type UseIap = {
58
63
  skus: string[];
59
64
  type?: 'inapp' | 'subs';
60
65
  }) => Promise<void>;
61
- /** @deprecated Use requestProducts({ skus, type: 'inapp' }) instead. This method will be removed in version 3.0.0. */
66
+ /**
67
+ * @deprecated Use requestProducts({ skus, type: 'inapp' }) instead. This method will be removed in version 3.0.0.
68
+ * Note: This method internally uses requestProducts, so no deprecation warning is shown.
69
+ */
62
70
  getProducts: (skus: string[]) => Promise<void>;
63
- /** @deprecated Use requestProducts({ skus, type: 'subs' }) instead. This method will be removed in version 3.0.0. */
71
+ /**
72
+ * @deprecated Use requestProducts({ skus, type: 'subs' }) instead. This method will be removed in version 3.0.0.
73
+ * Note: This method internally uses requestProducts, so no deprecation warning is shown.
74
+ */
64
75
  getSubscriptions: (skus: string[]) => Promise<void>;
65
76
  requestPurchase: (params: {
66
77
  request: RequestPurchaseProps | RequestSubscriptionProps;
@@ -93,9 +104,7 @@ export interface UseIAPOptions {
93
104
  export function useIAP(options?: UseIAPOptions): UseIap {
94
105
  const [connected, setConnected] = useState<boolean>(false);
95
106
  const [products, setProducts] = useState<Product[]>([]);
96
- const [promotedProductsIOS] = useState<
97
- ProductPurchase[]
98
- >([]);
107
+ const [promotedProductsIOS] = useState<ProductPurchase[]>([]);
99
108
  const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
100
109
  const [purchaseHistories, setPurchaseHistories] = useState<ProductPurchase[]>(
101
110
  [],
@@ -387,7 +396,7 @@ export function useIAP(options?: UseIAPOptions): UseIap {
387
396
  subscriptionsRef.current.promotedProductsIos =
388
397
  promotedProductListenerIOS((product: Product) => {
389
398
  setPromotedProductIOS(product);
390
-
399
+
391
400
  if (optionsRef.current?.onPromotedProductIOS) {
392
401
  optionsRef.current.onPromotedProductIOS(product);
393
402
  }
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>