react-native-iap 11.0.0-beta.1 → 11.0.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.
Files changed (55) hide show
  1. package/README.md +0 -1
  2. package/ios/IapSerializationUtils.swift +30 -0
  3. package/ios/RNIapIosSk2.m +5 -0
  4. package/ios/RNIapIosSk2.swift +63 -49
  5. package/lib/commonjs/eventEmitter.js +4 -4
  6. package/lib/commonjs/eventEmitter.js.map +1 -1
  7. package/lib/commonjs/hooks/withIAPContext.js +1 -1
  8. package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
  9. package/lib/commonjs/iap.js +50 -297
  10. package/lib/commonjs/iap.js.map +1 -1
  11. package/lib/commonjs/internal/platform.js +75 -2
  12. package/lib/commonjs/internal/platform.js.map +1 -1
  13. package/lib/commonjs/modules/amazon.js +28 -1
  14. package/lib/commonjs/modules/amazon.js.map +1 -1
  15. package/lib/commonjs/modules/android.js +73 -1
  16. package/lib/commonjs/modules/android.js.map +1 -1
  17. package/lib/commonjs/modules/ios.js +126 -0
  18. package/lib/commonjs/modules/ios.js.map +1 -1
  19. package/lib/commonjs/modules/iosSk2.js +47 -0
  20. package/lib/commonjs/modules/iosSk2.js.map +1 -1
  21. package/lib/commonjs/types/appleSk2.js.map +1 -1
  22. package/lib/module/eventEmitter.js +2 -2
  23. package/lib/module/eventEmitter.js.map +1 -1
  24. package/lib/module/hooks/withIAPContext.js +2 -2
  25. package/lib/module/hooks/withIAPContext.js.map +1 -1
  26. package/lib/module/iap.js +8 -223
  27. package/lib/module/iap.js.map +1 -1
  28. package/lib/module/internal/platform.js +48 -1
  29. package/lib/module/internal/platform.js.map +1 -1
  30. package/lib/module/modules/amazon.js +23 -0
  31. package/lib/module/modules/amazon.js.map +1 -1
  32. package/lib/module/modules/android.js +59 -1
  33. package/lib/module/modules/android.js.map +1 -1
  34. package/lib/module/modules/ios.js +102 -1
  35. package/lib/module/modules/ios.js.map +1 -1
  36. package/lib/module/modules/iosSk2.js +30 -1
  37. package/lib/module/modules/iosSk2.js.map +1 -1
  38. package/lib/module/types/appleSk2.js.map +1 -1
  39. package/lib/typescript/iap.d.ts +7 -120
  40. package/lib/typescript/internal/platform.d.ts +9 -0
  41. package/lib/typescript/modules/amazon.d.ts +17 -0
  42. package/lib/typescript/modules/android.d.ts +38 -1
  43. package/lib/typescript/modules/ios.d.ts +56 -0
  44. package/lib/typescript/modules/iosSk2.d.ts +27 -1
  45. package/lib/typescript/types/appleSk2.d.ts +4 -0
  46. package/package.json +1 -1
  47. package/src/eventEmitter.ts +4 -3
  48. package/src/hooks/withIAPContext.tsx +2 -2
  49. package/src/iap.ts +20 -297
  50. package/src/internal/platform.ts +78 -1
  51. package/src/modules/amazon.ts +29 -1
  52. package/src/modules/android.ts +83 -2
  53. package/src/modules/ios.ts +121 -0
  54. package/src/modules/iosSk2.ts +45 -1
  55. package/src/types/appleSk2.ts +12 -0
@@ -1,7 +1,15 @@
1
+ import {NativeModules} from 'react-native';
2
+
1
3
  import type {Product, ProductPurchase, Purchase, Sku} from '../types';
2
- import type {PaymentDiscountSk2, ProductSk2} from '../types/appleSk2';
4
+ import type {
5
+ PaymentDiscountSk2,
6
+ ProductSk2,
7
+ ProductStatus,
8
+ TransactionSk2,
9
+ } from '../types/appleSk2';
3
10
 
4
11
  import type {NativeModuleProps} from './common';
12
+ const {RNIapIosSk2} = NativeModules;
5
13
 
6
14
  type getItems = (skus: Sku[]) => Promise<ProductSk2[]>;
7
15
 
@@ -27,6 +35,11 @@ type getPendingTransactions = () => Promise<ProductPurchase[]>;
27
35
  type presentCodeRedemptionSheet = () => Promise<null>;
28
36
 
29
37
  export interface IosModulePropsSk2 extends NativeModuleProps {
38
+ latestTransaction(sku: string): Promise<TransactionSk2>;
39
+ currentEntitlement(sku: string): Promise<TransactionSk2>;
40
+ subscriptionStatus(sku: string): Promise<ProductStatus[]>;
41
+ isEligibleForIntroOffer(groupID: string): Promise<Boolean>;
42
+ sync(): Promise<null>;
30
43
  getItems: getItems;
31
44
  getAvailableItems: getAvailableItems;
32
45
  buyProduct: BuyProduct;
@@ -39,3 +52,34 @@ export interface IosModulePropsSk2 extends NativeModuleProps {
39
52
  getPendingTransactions: getPendingTransactions;
40
53
  presentCodeRedemptionSheet: presentCodeRedemptionSheet;
41
54
  }
55
+
56
+ /**
57
+ * Sync state with Appstore (iOS only)
58
+ * https://developer.apple.com/documentation/storekit/appstore/3791906-sync
59
+ */
60
+ export const sync = (): Promise<null> => RNIapIosSk2.sync();
61
+
62
+ /**
63
+ *
64
+ */
65
+ export const isEligibleForIntroOffer = (groupID: string): Promise<Boolean> =>
66
+ RNIapIosSk2.isEligibleForIntroOffer(groupID);
67
+
68
+ /**
69
+ *
70
+ */
71
+
72
+ export const subscriptionStatus = (sku: string): Promise<ProductStatus[]> =>
73
+ RNIapIosSk2.subscriptionStatus(sku);
74
+
75
+ /**
76
+ *
77
+ */
78
+ export const currentEntitlement = (sku: string): Promise<TransactionSk2> =>
79
+ RNIapIosSk2.currentEntitlement(sku);
80
+
81
+ /**
82
+ *
83
+ */
84
+ export const latestTransaction = (sku: string): Promise<TransactionSk2> =>
85
+ RNIapIosSk2.latestTransaction(sku);
@@ -74,6 +74,18 @@ export type TransactionSk2 = {
74
74
  subscriptionGroupID: number;
75
75
  webOrderLineItemID: number;
76
76
  };
77
+
78
+ export type SubscriptionStatus =
79
+ | 'expired'
80
+ | 'inBillingRetryPeriod'
81
+ | 'inGracePeriod'
82
+ | 'revoked'
83
+ | 'subscribed';
84
+
85
+ export type ProductStatus = {
86
+ state: SubscriptionStatus;
87
+ };
88
+
77
89
  export const transactionSk2Map = ({
78
90
  id,
79
91
  originalPurchaseDate,