expo-iap 2.6.0 → 2.6.1

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.
@@ -28,36 +28,75 @@ export declare function isProductIos<T extends {
28
28
  /**
29
29
  * Sync state with Appstore (iOS only)
30
30
  * https://developer.apple.com/documentation/storekit/appstore/3791906-sync
31
+ *
32
+ * @returns Promise resolving to null on success
33
+ * @throws Error if called on non-iOS platform
34
+ *
35
+ * @platform iOS
31
36
  */
32
- export declare const sync: () => Promise<null>;
37
+ export declare const syncIOS: () => Promise<null>;
33
38
  /**
39
+ * Check if user is eligible for introductory offer
34
40
  *
41
+ * @param groupID The subscription group ID
42
+ * @returns Promise resolving to true if eligible
43
+ * @throws Error if called on non-iOS platform
44
+ *
45
+ * @platform iOS
35
46
  */
36
- export declare const isEligibleForIntroOffer: (groupID: string) => Promise<boolean>;
47
+ export declare const isEligibleForIntroOfferIOS: (groupID: string) => Promise<boolean>;
37
48
  /**
49
+ * Get subscription status for a specific SKU
38
50
  *
51
+ * @param sku The product SKU
52
+ * @returns Promise resolving to array of subscription status
53
+ * @throws Error if called on non-iOS platform
54
+ *
55
+ * @platform iOS
39
56
  */
40
- export declare const subscriptionStatus: (sku: string) => Promise<ProductStatusIos[]>;
57
+ export declare const subscriptionStatusIOS: (sku: string) => Promise<ProductStatusIos[]>;
41
58
  /**
59
+ * Get current entitlement for a specific SKU
42
60
  *
61
+ * @param sku The product SKU
62
+ * @returns Promise resolving to current entitlement
63
+ * @throws Error if called on non-iOS platform
64
+ *
65
+ * @platform iOS
43
66
  */
44
- export declare const currentEntitlement: (sku: string) => Promise<ProductPurchase>;
67
+ export declare const currentEntitlementIOS: (sku: string) => Promise<ProductPurchase>;
45
68
  /**
69
+ * Get latest transaction for a specific SKU
46
70
  *
71
+ * @param sku The product SKU
72
+ * @returns Promise resolving to latest transaction
73
+ * @throws Error if called on non-iOS platform
74
+ *
75
+ * @platform iOS
47
76
  */
48
- export declare const latestTransaction: (sku: string) => Promise<ProductPurchase>;
77
+ export declare const latestTransactionIOS: (sku: string) => Promise<ProductPurchase>;
49
78
  /**
79
+ * Begin refund request for a specific SKU
80
+ *
81
+ * @param sku The product SKU
82
+ * @returns Promise resolving to refund request status
83
+ * @throws Error if called on non-iOS platform
50
84
  *
85
+ * @platform iOS
51
86
  */
52
87
  type RefundRequestStatus = 'success' | 'userCancelled';
53
- export declare const beginRefundRequest: (sku: string) => Promise<RefundRequestStatus>;
88
+ export declare const beginRefundRequestIOS: (sku: string) => Promise<RefundRequestStatus>;
54
89
  /**
55
90
  * Shows the system UI for managing subscriptions.
56
91
  * When the user changes subscription renewal status, the system will emit events to
57
92
  * purchaseUpdatedListener and transactionUpdatedIos listeners.
58
- * @returns {Promise<null>}
93
+ *
94
+ * @returns Promise resolving to null on success
95
+ * @throws Error if called on non-iOS platform
96
+ *
97
+ * @platform iOS
59
98
  */
60
- export declare const showManageSubscriptions: () => Promise<null>;
99
+ export declare const showManageSubscriptionsIOS: () => Promise<null>;
61
100
  /**
62
101
  * Get the receipt data from the iOS device.
63
102
  * This returns the base64 encoded receipt data which can be sent to your server
@@ -68,23 +107,29 @@ export declare const showManageSubscriptions: () => Promise<null>;
68
107
  *
69
108
  * @returns {Promise<string>} Base64 encoded receipt data
70
109
  */
71
- export declare const getReceiptIos: () => Promise<string>;
110
+ export declare const getReceiptIOS: () => Promise<string>;
72
111
  /**
73
112
  * Check if a transaction is verified through StoreKit 2.
74
113
  * StoreKit 2 performs local verification of transaction JWS signatures.
75
114
  *
76
- * @param {string} sku The product's SKU (on iOS)
77
- * @returns {Promise<boolean>} True if the transaction is verified
115
+ * @param sku The product's SKU (on iOS)
116
+ * @returns Promise resolving to true if the transaction is verified
117
+ * @throws Error if called on non-iOS platform
118
+ *
119
+ * @platform iOS
78
120
  */
79
- export declare const isTransactionVerified: (sku: string) => Promise<boolean>;
121
+ export declare const isTransactionVerifiedIOS: (sku: string) => Promise<boolean>;
80
122
  /**
81
123
  * Get the JWS representation of a purchase for server-side verification.
82
124
  * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.
83
125
  *
84
- * @param {string} sku The product's SKU (on iOS)
85
- * @returns {Promise<string>} JWS representation of the transaction
126
+ * @param sku The product's SKU (on iOS)
127
+ * @returns Promise resolving to JWS representation of the transaction
128
+ * @throws Error if called on non-iOS platform
129
+ *
130
+ * @platform iOS
86
131
  */
87
- export declare const getTransactionJws: (sku: string) => Promise<string>;
132
+ export declare const getTransactionJwsIOS: (sku: string) => Promise<string>;
88
133
  /**
89
134
  * Validate receipt for iOS using StoreKit 2's built-in verification.
90
135
  * Returns receipt data and verification information to help with server-side validation.
@@ -100,7 +145,7 @@ export declare const getTransactionJws: (sku: string) => Promise<string>;
100
145
  * latestTransaction?: ProductPurchase;
101
146
  * }>}
102
147
  */
103
- export declare const validateReceiptIos: (sku: string) => Promise<{
148
+ export declare const validateReceiptIOS: (sku: string) => Promise<{
104
149
  isValid: boolean;
105
150
  receiptData: string;
106
151
  jwsRepresentation: string;
@@ -112,16 +157,77 @@ export declare const validateReceiptIos: (sku: string) => Promise<{
112
157
  *
113
158
  * Note: This only works on real devices, not simulators.
114
159
  *
115
- * @returns {Promise<boolean>} True if the sheet was presented successfully
116
- * @throws {Error} If called on non-iOS platform or tvOS
160
+ * @returns Promise resolving to true if the sheet was presented successfully
161
+ * @throws Error if called on non-iOS platform or tvOS
162
+ *
163
+ * @platform iOS
117
164
  */
118
- export declare const presentCodeRedemptionSheet: () => Promise<boolean>;
165
+ export declare const presentCodeRedemptionSheetIOS: () => Promise<boolean>;
119
166
  /**
120
167
  * Get app transaction information (iOS 16.0+).
121
168
  * AppTransaction represents the initial purchase that unlocked the app.
122
169
  *
123
- * @returns {Promise<AppTransactionIOS | null>} The app transaction information or null if not available
124
- * @throws {Error} If called on non-iOS platform or iOS version < 16.0
170
+ * @returns Promise resolving to the app transaction information or null if not available
171
+ * @throws Error if called on non-iOS platform or iOS version < 16.0
172
+ *
173
+ * @platform iOS
174
+ */
175
+ export declare const getAppTransactionIOS: () => Promise<AppTransactionIOS | null>;
176
+ /**
177
+ * @deprecated Use `syncIOS` instead. This function will be removed in version 3.0.0.
178
+ */
179
+ export declare const sync: () => Promise<null>;
180
+ /**
181
+ * @deprecated Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.
182
+ */
183
+ export declare const isEligibleForIntroOffer: (groupID: string) => Promise<boolean>;
184
+ /**
185
+ * @deprecated Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.
186
+ */
187
+ export declare const subscriptionStatus: (sku: string) => Promise<ProductStatusIos[]>;
188
+ /**
189
+ * @deprecated Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.
190
+ */
191
+ export declare const currentEntitlement: (sku: string) => Promise<ProductPurchase>;
192
+ /**
193
+ * @deprecated Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.
194
+ */
195
+ export declare const latestTransaction: (sku: string) => Promise<ProductPurchase>;
196
+ /**
197
+ * @deprecated Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.
198
+ */
199
+ export declare const beginRefundRequest: (sku: string) => Promise<RefundRequestStatus>;
200
+ /**
201
+ * @deprecated Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.
202
+ */
203
+ export declare const showManageSubscriptions: () => Promise<null>;
204
+ /**
205
+ * @deprecated Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.
206
+ */
207
+ export declare const getReceiptIos: () => Promise<string>;
208
+ /**
209
+ * @deprecated Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.
210
+ */
211
+ export declare const isTransactionVerified: (sku: string) => Promise<boolean>;
212
+ /**
213
+ * @deprecated Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.
214
+ */
215
+ export declare const getTransactionJws: (sku: string) => Promise<string>;
216
+ /**
217
+ * @deprecated Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.
218
+ */
219
+ export declare const validateReceiptIos: (sku: string) => Promise<{
220
+ isValid: boolean;
221
+ receiptData: string;
222
+ jwsRepresentation: string;
223
+ latestTransaction?: ProductPurchase;
224
+ }>;
225
+ /**
226
+ * @deprecated Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.
227
+ */
228
+ export declare const presentCodeRedemptionSheet: () => Promise<boolean>;
229
+ /**
230
+ * @deprecated Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.
125
231
  */
126
232
  export declare const getAppTransaction: () => Promise<AppTransactionIOS | null>;
127
233
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,aAAa,EAGd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAGnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAGF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI;;CAsC5C,CAAC;AAGF,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,EACxD,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,CAAC,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAA;CAAC,CAO/B;AAGD;;;GAGG;AACH,eAAO,MAAM,IAAI,QAAO,OAAO,CAAC,IAAI,CAAyB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,MAAM,KAAG,OAAO,CAAC,OAAO,CACzB,CAAC;AAEjD;;GAEG;AAEH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,gBAAgB,EAAE,CACpC,CA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BAAmB,CAK7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAO,OAAO,CAAC,IAAI,CAKtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,OAAO,CAAC,MAAM,CAK9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAKlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CAK7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,KAAK,MAAM,KACV,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,eAAe,CAAC;CACrC,CAKA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,QAAO,OAAO,CAAC,OAAO,CAK5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAKpE,CAAC"}
@@ -1,4 +1,6 @@
1
+ // External dependencies
1
2
  import { Platform } from 'react-native';
3
+ // Internal modules
2
4
  import { purchaseUpdatedListener } from '..';
3
5
  import ExpoIapModule from '../ExpoIapModule';
4
6
  // Listeners
@@ -56,32 +58,100 @@ export function isProductIos(item) {
56
58
  /**
57
59
  * Sync state with Appstore (iOS only)
58
60
  * https://developer.apple.com/documentation/storekit/appstore/3791906-sync
61
+ *
62
+ * @returns Promise resolving to null on success
63
+ * @throws Error if called on non-iOS platform
64
+ *
65
+ * @platform iOS
59
66
  */
60
- export const sync = () => ExpoIapModule.sync();
67
+ export const syncIOS = () => {
68
+ if (Platform.OS !== 'ios') {
69
+ throw new Error('syncIOS: This method is only available on iOS');
70
+ }
71
+ return ExpoIapModule.sync();
72
+ };
61
73
  /**
74
+ * Check if user is eligible for introductory offer
75
+ *
76
+ * @param groupID The subscription group ID
77
+ * @returns Promise resolving to true if eligible
78
+ * @throws Error if called on non-iOS platform
62
79
  *
80
+ * @platform iOS
63
81
  */
64
- export const isEligibleForIntroOffer = (groupID) => ExpoIapModule.isEligibleForIntroOffer(groupID);
82
+ export const isEligibleForIntroOfferIOS = (groupID) => {
83
+ if (Platform.OS !== 'ios') {
84
+ throw new Error('isEligibleForIntroOfferIOS: This method is only available on iOS');
85
+ }
86
+ return ExpoIapModule.isEligibleForIntroOffer(groupID);
87
+ };
65
88
  /**
89
+ * Get subscription status for a specific SKU
66
90
  *
91
+ * @param sku The product SKU
92
+ * @returns Promise resolving to array of subscription status
93
+ * @throws Error if called on non-iOS platform
94
+ *
95
+ * @platform iOS
67
96
  */
68
- export const subscriptionStatus = (sku) => ExpoIapModule.subscriptionStatus(sku);
97
+ export const subscriptionStatusIOS = (sku) => {
98
+ if (Platform.OS !== 'ios') {
99
+ throw new Error('subscriptionStatusIOS: This method is only available on iOS');
100
+ }
101
+ return ExpoIapModule.subscriptionStatus(sku);
102
+ };
69
103
  /**
104
+ * Get current entitlement for a specific SKU
105
+ *
106
+ * @param sku The product SKU
107
+ * @returns Promise resolving to current entitlement
108
+ * @throws Error if called on non-iOS platform
70
109
  *
110
+ * @platform iOS
71
111
  */
72
- export const currentEntitlement = (sku) => ExpoIapModule.currentEntitlement(sku);
112
+ export const currentEntitlementIOS = (sku) => {
113
+ if (Platform.OS !== 'ios') {
114
+ throw new Error('currentEntitlementIOS: This method is only available on iOS');
115
+ }
116
+ return ExpoIapModule.currentEntitlement(sku);
117
+ };
73
118
  /**
119
+ * Get latest transaction for a specific SKU
120
+ *
121
+ * @param sku The product SKU
122
+ * @returns Promise resolving to latest transaction
123
+ * @throws Error if called on non-iOS platform
74
124
  *
125
+ * @platform iOS
75
126
  */
76
- export const latestTransaction = (sku) => ExpoIapModule.latestTransaction(sku);
77
- export const beginRefundRequest = (sku) => ExpoIapModule.beginRefundRequest(sku);
127
+ export const latestTransactionIOS = (sku) => {
128
+ if (Platform.OS !== 'ios') {
129
+ throw new Error('latestTransactionIOS: This method is only available on iOS');
130
+ }
131
+ return ExpoIapModule.latestTransaction(sku);
132
+ };
133
+ export const beginRefundRequestIOS = (sku) => {
134
+ if (Platform.OS !== 'ios') {
135
+ throw new Error('beginRefundRequestIOS: This method is only available on iOS');
136
+ }
137
+ return ExpoIapModule.beginRefundRequest(sku);
138
+ };
78
139
  /**
79
140
  * Shows the system UI for managing subscriptions.
80
141
  * When the user changes subscription renewal status, the system will emit events to
81
142
  * purchaseUpdatedListener and transactionUpdatedIos listeners.
82
- * @returns {Promise<null>}
143
+ *
144
+ * @returns Promise resolving to null on success
145
+ * @throws Error if called on non-iOS platform
146
+ *
147
+ * @platform iOS
83
148
  */
84
- export const showManageSubscriptions = () => ExpoIapModule.showManageSubscriptions();
149
+ export const showManageSubscriptionsIOS = () => {
150
+ if (Platform.OS !== 'ios') {
151
+ throw new Error('showManageSubscriptionsIOS: This method is only available on iOS');
152
+ }
153
+ return ExpoIapModule.showManageSubscriptions();
154
+ };
85
155
  /**
86
156
  * Get the receipt data from the iOS device.
87
157
  * This returns the base64 encoded receipt data which can be sent to your server
@@ -92,7 +162,7 @@ export const showManageSubscriptions = () => ExpoIapModule.showManageSubscriptio
92
162
  *
93
163
  * @returns {Promise<string>} Base64 encoded receipt data
94
164
  */
95
- export const getReceiptIos = () => {
165
+ export const getReceiptIOS = () => {
96
166
  if (Platform.OS !== 'ios') {
97
167
  throw new Error('This method is only available on iOS');
98
168
  }
@@ -102,12 +172,15 @@ export const getReceiptIos = () => {
102
172
  * Check if a transaction is verified through StoreKit 2.
103
173
  * StoreKit 2 performs local verification of transaction JWS signatures.
104
174
  *
105
- * @param {string} sku The product's SKU (on iOS)
106
- * @returns {Promise<boolean>} True if the transaction is verified
175
+ * @param sku The product's SKU (on iOS)
176
+ * @returns Promise resolving to true if the transaction is verified
177
+ * @throws Error if called on non-iOS platform
178
+ *
179
+ * @platform iOS
107
180
  */
108
- export const isTransactionVerified = (sku) => {
181
+ export const isTransactionVerifiedIOS = (sku) => {
109
182
  if (Platform.OS !== 'ios') {
110
- throw new Error('This method is only available on iOS');
183
+ throw new Error('isTransactionVerifiedIOS: This method is only available on iOS');
111
184
  }
112
185
  return ExpoIapModule.isTransactionVerified(sku);
113
186
  };
@@ -115,12 +188,15 @@ export const isTransactionVerified = (sku) => {
115
188
  * Get the JWS representation of a purchase for server-side verification.
116
189
  * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.
117
190
  *
118
- * @param {string} sku The product's SKU (on iOS)
119
- * @returns {Promise<string>} JWS representation of the transaction
191
+ * @param sku The product's SKU (on iOS)
192
+ * @returns Promise resolving to JWS representation of the transaction
193
+ * @throws Error if called on non-iOS platform
194
+ *
195
+ * @platform iOS
120
196
  */
121
- export const getTransactionJws = (sku) => {
197
+ export const getTransactionJwsIOS = (sku) => {
122
198
  if (Platform.OS !== 'ios') {
123
- throw new Error('This method is only available on iOS');
199
+ throw new Error('getTransactionJwsIOS: This method is only available on iOS');
124
200
  }
125
201
  return ExpoIapModule.getTransactionJws(sku);
126
202
  };
@@ -139,11 +215,11 @@ export const getTransactionJws = (sku) => {
139
215
  * latestTransaction?: ProductPurchase;
140
216
  * }>}
141
217
  */
142
- export const validateReceiptIos = async (sku) => {
218
+ export const validateReceiptIOS = async (sku) => {
143
219
  if (Platform.OS !== 'ios') {
144
220
  throw new Error('This method is only available on iOS');
145
221
  }
146
- const result = await ExpoIapModule.validateReceiptIos(sku);
222
+ const result = await ExpoIapModule.validateReceiptIOS(sku);
147
223
  return result;
148
224
  };
149
225
  /**
@@ -152,12 +228,14 @@ export const validateReceiptIos = async (sku) => {
152
228
  *
153
229
  * Note: This only works on real devices, not simulators.
154
230
  *
155
- * @returns {Promise<boolean>} True if the sheet was presented successfully
156
- * @throws {Error} If called on non-iOS platform or tvOS
231
+ * @returns Promise resolving to true if the sheet was presented successfully
232
+ * @throws Error if called on non-iOS platform or tvOS
233
+ *
234
+ * @platform iOS
157
235
  */
158
- export const presentCodeRedemptionSheet = () => {
236
+ export const presentCodeRedemptionSheetIOS = () => {
159
237
  if (Platform.OS !== 'ios') {
160
- throw new Error('This method is only available on iOS');
238
+ throw new Error('presentCodeRedemptionSheetIOS: This method is only available on iOS');
161
239
  }
162
240
  return ExpoIapModule.presentCodeRedemptionSheet();
163
241
  };
@@ -165,13 +243,108 @@ export const presentCodeRedemptionSheet = () => {
165
243
  * Get app transaction information (iOS 16.0+).
166
244
  * AppTransaction represents the initial purchase that unlocked the app.
167
245
  *
168
- * @returns {Promise<AppTransactionIOS | null>} The app transaction information or null if not available
169
- * @throws {Error} If called on non-iOS platform or iOS version < 16.0
246
+ * @returns Promise resolving to the app transaction information or null if not available
247
+ * @throws Error if called on non-iOS platform or iOS version < 16.0
248
+ *
249
+ * @platform iOS
170
250
  */
171
- export const getAppTransaction = () => {
251
+ export const getAppTransactionIOS = () => {
172
252
  if (Platform.OS !== 'ios') {
173
- throw new Error('This method is only available on iOS');
253
+ throw new Error('getAppTransactionIOS: This method is only available on iOS');
174
254
  }
175
255
  return ExpoIapModule.getAppTransaction();
176
256
  };
257
+ // ============= DEPRECATED FUNCTIONS =============
258
+ // These will be removed in version 3.0.0
259
+ /**
260
+ * @deprecated Use `syncIOS` instead. This function will be removed in version 3.0.0.
261
+ */
262
+ export const sync = () => {
263
+ console.warn('`sync` is deprecated. Use `syncIOS` instead. This function will be removed in version 3.0.0.');
264
+ return syncIOS();
265
+ };
266
+ /**
267
+ * @deprecated Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.
268
+ */
269
+ export const isEligibleForIntroOffer = (groupID) => {
270
+ console.warn('`isEligibleForIntroOffer` is deprecated. Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.');
271
+ return isEligibleForIntroOfferIOS(groupID);
272
+ };
273
+ /**
274
+ * @deprecated Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.
275
+ */
276
+ export const subscriptionStatus = (sku) => {
277
+ console.warn('`subscriptionStatus` is deprecated. Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.');
278
+ return subscriptionStatusIOS(sku);
279
+ };
280
+ /**
281
+ * @deprecated Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.
282
+ */
283
+ export const currentEntitlement = (sku) => {
284
+ console.warn('`currentEntitlement` is deprecated. Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.');
285
+ return currentEntitlementIOS(sku);
286
+ };
287
+ /**
288
+ * @deprecated Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.
289
+ */
290
+ export const latestTransaction = (sku) => {
291
+ console.warn('`latestTransaction` is deprecated. Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.');
292
+ return latestTransactionIOS(sku);
293
+ };
294
+ /**
295
+ * @deprecated Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.
296
+ */
297
+ export const beginRefundRequest = (sku) => {
298
+ console.warn('`beginRefundRequest` is deprecated. Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.');
299
+ return beginRefundRequestIOS(sku);
300
+ };
301
+ /**
302
+ * @deprecated Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.
303
+ */
304
+ export const showManageSubscriptions = () => {
305
+ console.warn('`showManageSubscriptions` is deprecated. Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.');
306
+ return showManageSubscriptionsIOS();
307
+ };
308
+ /**
309
+ * @deprecated Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.
310
+ */
311
+ export const getReceiptIos = () => {
312
+ console.warn('`getReceiptIos` is deprecated. Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.');
313
+ return getReceiptIOS();
314
+ };
315
+ /**
316
+ * @deprecated Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.
317
+ */
318
+ export const isTransactionVerified = (sku) => {
319
+ console.warn('`isTransactionVerified` is deprecated. Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.');
320
+ return isTransactionVerifiedIOS(sku);
321
+ };
322
+ /**
323
+ * @deprecated Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.
324
+ */
325
+ export const getTransactionJws = (sku) => {
326
+ console.warn('`getTransactionJws` is deprecated. Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.');
327
+ return getTransactionJwsIOS(sku);
328
+ };
329
+ /**
330
+ * @deprecated Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.
331
+ */
332
+ export const validateReceiptIos = async (sku) => {
333
+ console.warn('`validateReceiptIos` is deprecated. Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.');
334
+ return validateReceiptIOS(sku);
335
+ };
336
+ /**
337
+ * @deprecated Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.
338
+ */
339
+ export const presentCodeRedemptionSheet = () => {
340
+ console.warn('`presentCodeRedemptionSheet` is deprecated. Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.');
341
+ return presentCodeRedemptionSheetIOS();
342
+ };
343
+ /**
344
+ * @deprecated Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.
345
+ */
346
+ export const getAppTransaction = () => {
347
+ console.warn('`getAppTransaction` is deprecated. Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.');
348
+ return getAppTransactionIOS();
349
+ };
177
350
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,uBAAuB,EAAC,MAAM,IAAI,CAAC;AAW3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,YAAY;AACZ;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C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,EAAE;IAChE,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EAMV,EAAE;IACH,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAqB,EAAE;IAC/D,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAsC,EAAE;IACvE,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,iBAAiB,EAAE,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {purchaseUpdatedListener} from '..';\nimport {\n ProductPurchase,\n PurchaseError,\n Purchase,\n SubscriptionPurchase,\n} from '../ExpoIap.types';\nimport type {\n ProductStatusIos,\n AppTransactionIOS,\n} from '../types/ExpoIapIos.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\nexport type TransactionEvent = {\n transaction?: ProductPurchase;\n error?: PurchaseError;\n};\n\n// Listeners\n/**\n * @deprecated Use `purchaseUpdatedListener` instead. This function will be removed in a future version.\n *\n * The `transactionUpdatedIos` function is redundant as it simply wraps `purchaseUpdatedListener`.\n * You can achieve the same functionality by using `purchaseUpdatedListener` directly.\n *\n * @example\n * // Instead of:\n * // transactionUpdatedIos((event) => { ... });\n *\n * // Use:\n * // purchaseUpdatedListener((purchase) => { ... });\n */\nexport const transactionUpdatedIos = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const isProductPurchase = (item: unknown): item is ProductPurchase => {\n return (\n item != null &&\n typeof item === 'object' &&\n 'id' in item &&\n 'transactionId' in item &&\n 'platform' in item\n );\n };\n\n // Helper function to safely convert Purchase to TransactionEvent\n const mapPurchaseToTransactionEvent = (\n purchase: Purchase | SubscriptionPurchase,\n ): TransactionEvent => {\n // Validate the purchase object before casting\n if (isProductPurchase(purchase)) {\n return {\n transaction: purchase as ProductPurchase,\n };\n }\n\n // Fallback: create a basic TransactionEvent structure\n return {\n transaction: purchase as ProductPurchase,\n };\n };\n\n return purchaseUpdatedListener((purchase) => {\n // Convert Purchase to TransactionEvent format for backward compatibility\n const event = mapPurchaseToTransactionEvent(purchase);\n listener(event);\n });\n};\n\n// Type guards\nexport function isProductIos<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => ExpoIapModule.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<boolean> =>\n ExpoIapModule.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatusIos[]> =>\n ExpoIapModule.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.latestTransaction(sku);\n\n/**\n *\n */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>\n ExpoIapModule.beginRefundRequest(sku);\n\n/**\n * Shows the system UI for managing subscriptions.\n * When the user changes subscription renewal status, the system will emit events to\n * purchaseUpdatedListener and transactionUpdatedIos listeners.\n * @returns {Promise<null>}\n */\nexport const showManageSubscriptions = (): Promise<null> =>\n ExpoIapModule.showManageSubscriptions();\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptIos = (): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getReceiptData();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<boolean>} True if the transaction is verified\n */\nexport const isTransactionVerified = (sku: string): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.isTransactionVerified(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<string>} JWS representation of the transaction\n */\nexport const getTransactionJws = (sku: string): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getTransactionJws(sku);\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: ProductPurchase;\n * }>}\n */\nexport const validateReceiptIos = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: ProductPurchase;\n}> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const result = await ExpoIapModule.validateReceiptIos(sku);\n return result;\n};\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns {Promise<boolean>} True if the sheet was presented successfully\n * @throws {Error} If called on non-iOS platform or tvOS\n */\nexport const presentCodeRedemptionSheet = (): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.presentCodeRedemptionSheet();\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * @returns {Promise<AppTransactionIOS | null>} The app transaction information or null if not available\n * @throws {Error} If called on non-iOS platform or iOS version < 16.0\n */\nexport const getAppTransaction = (): Promise<AppTransactionIOS | null> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getAppTransaction();\n};\n"]}
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAEtC,mBAAmB;AACnB,OAAO,EAAC,uBAAuB,EAAC,MAAM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,qBAAqB,GAAG,CAAC,GAAW,EAAoB,EAAE;IACrE,OAAO,CAAC,IAAI,CACV,gIAAgI,CACjI,CAAC;IACF,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAmB,EAAE;IAChE,OAAO,CAAC,IAAI,CACV,wHAAwH,CACzH,CAAC;IACF,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EAMV,EAAE;IACH,OAAO,CAAC,IAAI,CACV,uHAAuH,CACxH,CAAC;IACF,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAqB,EAAE;IAC/D,OAAO,CAAC,IAAI,CACV,0IAA0I,CAC3I,CAAC;IACF,OAAO,6BAA6B,EAAE,CAAC;AACzC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAsC,EAAE;IACvE,OAAO,CAAC,IAAI,CACV,wHAAwH,CACzH,CAAC;IACF,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC,CAAC","sourcesContent":["// External dependencies\nimport {Platform} from 'react-native';\n\n// Internal modules\nimport {purchaseUpdatedListener} from '..';\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport {\n ProductPurchase,\n PurchaseError,\n Purchase,\n SubscriptionPurchase,\n} from '../ExpoIap.types';\nimport type {\n ProductStatusIos,\n AppTransactionIOS,\n} from '../types/ExpoIapIos.types';\n\nexport type TransactionEvent = {\n transaction?: ProductPurchase;\n error?: PurchaseError;\n};\n\n// Listeners\n/**\n * @deprecated Use `purchaseUpdatedListener` instead. This function will be removed in a future version.\n *\n * The `transactionUpdatedIos` function is redundant as it simply wraps `purchaseUpdatedListener`.\n * You can achieve the same functionality by using `purchaseUpdatedListener` directly.\n *\n * @example\n * // Instead of:\n * // transactionUpdatedIos((event) => { ... });\n *\n * // Use:\n * // purchaseUpdatedListener((purchase) => { ... });\n */\nexport const transactionUpdatedIos = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const isProductPurchase = (item: unknown): item is ProductPurchase => {\n return (\n item != null &&\n typeof item === 'object' &&\n 'id' in item &&\n 'transactionId' in item &&\n 'platform' in item\n );\n };\n\n // Helper function to safely convert Purchase to TransactionEvent\n const mapPurchaseToTransactionEvent = (\n purchase: Purchase | SubscriptionPurchase,\n ): TransactionEvent => {\n // Validate the purchase object before casting\n if (isProductPurchase(purchase)) {\n return {\n transaction: purchase as ProductPurchase,\n };\n }\n\n // Fallback: create a basic TransactionEvent structure\n return {\n transaction: purchase as ProductPurchase,\n };\n };\n\n return purchaseUpdatedListener((purchase) => {\n // Convert Purchase to TransactionEvent format for backward compatibility\n const event = mapPurchaseToTransactionEvent(purchase);\n listener(event);\n });\n};\n\n// Type guards\nexport function isProductIos<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to null on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const syncIOS = (): Promise<null> => {\n if (Platform.OS !== 'ios') {\n throw new Error('syncIOS: This method is only available on iOS');\n }\n return ExpoIapModule.sync();\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupID The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isEligibleForIntroOfferIOS = (\n groupID: string,\n): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'isEligibleForIntroOfferIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.isEligibleForIntroOffer(groupID);\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const subscriptionStatusIOS = (\n sku: string,\n): Promise<ProductStatusIos[]> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'subscriptionStatusIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.subscriptionStatus(sku);\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const currentEntitlementIOS = (\n sku: string,\n): Promise<ProductPurchase> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'currentEntitlementIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.currentEntitlement(sku);\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const latestTransactionIOS = (sku: string): Promise<ProductPurchase> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'latestTransactionIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.latestTransaction(sku);\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequestIOS = (\n sku: string,\n): Promise<RefundRequestStatus> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'beginRefundRequestIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.beginRefundRequest(sku);\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * When the user changes subscription renewal status, the system will emit events to\n * purchaseUpdatedListener and transactionUpdatedIos listeners.\n *\n * @returns Promise resolving to null on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const showManageSubscriptionsIOS = (): Promise<null> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'showManageSubscriptionsIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.showManageSubscriptions();\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptIOS = (): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getReceiptData();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isTransactionVerifiedIOS = (sku: string): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'isTransactionVerifiedIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.isTransactionVerified(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getTransactionJwsIOS = (sku: string): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'getTransactionJwsIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.getTransactionJws(sku);\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: ProductPurchase;\n * }>}\n */\nexport const validateReceiptIOS = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: ProductPurchase;\n}> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const result = await ExpoIapModule.validateReceiptIOS(sku);\n return result;\n};\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns Promise resolving to true if the sheet was presented successfully\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n */\nexport const presentCodeRedemptionSheetIOS = (): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'presentCodeRedemptionSheetIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.presentCodeRedemptionSheet();\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform or iOS version < 16.0\n *\n * @platform iOS\n */\nexport const getAppTransactionIOS = (): Promise<AppTransactionIOS | null> => {\n if (Platform.OS !== 'ios') {\n throw new Error(\n 'getAppTransactionIOS: This method is only available on iOS',\n );\n }\n return ExpoIapModule.getAppTransaction();\n};\n\n// ============= DEPRECATED FUNCTIONS =============\n// These will be removed in version 3.0.0\n\n/**\n * @deprecated Use `syncIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const sync = (): Promise<null> => {\n console.warn(\n '`sync` is deprecated. Use `syncIOS` instead. This function will be removed in version 3.0.0.',\n );\n return syncIOS();\n};\n\n/**\n * @deprecated Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<boolean> => {\n console.warn(\n '`isEligibleForIntroOffer` is deprecated. Use `isEligibleForIntroOfferIOS` instead. This function will be removed in version 3.0.0.',\n );\n return isEligibleForIntroOfferIOS(groupID);\n};\n\n/**\n * @deprecated Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const subscriptionStatus = (\n sku: string,\n): Promise<ProductStatusIos[]> => {\n console.warn(\n '`subscriptionStatus` is deprecated. Use `subscriptionStatusIOS` instead. This function will be removed in version 3.0.0.',\n );\n return subscriptionStatusIOS(sku);\n};\n\n/**\n * @deprecated Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const currentEntitlement = (sku: string): Promise<ProductPurchase> => {\n console.warn(\n '`currentEntitlement` is deprecated. Use `currentEntitlementIOS` instead. This function will be removed in version 3.0.0.',\n );\n return currentEntitlementIOS(sku);\n};\n\n/**\n * @deprecated Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const latestTransaction = (sku: string): Promise<ProductPurchase> => {\n console.warn(\n '`latestTransaction` is deprecated. Use `latestTransactionIOS` instead. This function will be removed in version 3.0.0.',\n );\n return latestTransactionIOS(sku);\n};\n\n/**\n * @deprecated Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const beginRefundRequest = (\n sku: string,\n): Promise<RefundRequestStatus> => {\n console.warn(\n '`beginRefundRequest` is deprecated. Use `beginRefundRequestIOS` instead. This function will be removed in version 3.0.0.',\n );\n return beginRefundRequestIOS(sku);\n};\n\n/**\n * @deprecated Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const showManageSubscriptions = (): Promise<null> => {\n console.warn(\n '`showManageSubscriptions` is deprecated. Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.',\n );\n return showManageSubscriptionsIOS();\n};\n\n/**\n * @deprecated Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const getReceiptIos = (): Promise<string> => {\n console.warn(\n '`getReceiptIos` is deprecated. Use `getReceiptIOS` instead. This function will be removed in version 3.0.0.',\n );\n return getReceiptIOS();\n};\n\n/**\n * @deprecated Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const isTransactionVerified = (sku: string): Promise<boolean> => {\n console.warn(\n '`isTransactionVerified` is deprecated. Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.',\n );\n return isTransactionVerifiedIOS(sku);\n};\n\n/**\n * @deprecated Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const getTransactionJws = (sku: string): Promise<string> => {\n console.warn(\n '`getTransactionJws` is deprecated. Use `getTransactionJwsIOS` instead. This function will be removed in version 3.0.0.',\n );\n return getTransactionJwsIOS(sku);\n};\n\n/**\n * @deprecated Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const validateReceiptIos = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: ProductPurchase;\n}> => {\n console.warn(\n '`validateReceiptIos` is deprecated. Use `validateReceiptIOS` instead. This function will be removed in version 3.0.0.',\n );\n return validateReceiptIOS(sku);\n};\n\n/**\n * @deprecated Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const presentCodeRedemptionSheet = (): Promise<boolean> => {\n console.warn(\n '`presentCodeRedemptionSheet` is deprecated. Use `presentCodeRedemptionSheetIOS` instead. This function will be removed in version 3.0.0.',\n );\n return presentCodeRedemptionSheetIOS();\n};\n\n/**\n * @deprecated Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.\n */\nexport const getAppTransaction = (): Promise<AppTransactionIOS | null> => {\n console.warn(\n '`getAppTransaction` is deprecated. Use `getAppTransactionIOS` instead. This function will be removed in version 3.0.0.',\n );\n return getAppTransactionIOS();\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useIap.d.ts","sourceRoot":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IAAI,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CA0TtD"}
package/build/useIap.js CHANGED
@@ -1,8 +1,10 @@
1
- import { endConnection, initConnection, purchaseErrorListener, purchaseUpdatedListener, getProducts, getAvailablePurchases, getPurchaseHistories, finishTransaction as finishTransactionInternal, getSubscriptions, requestPurchase as requestPurchaseInternal, } from './';
2
- import { sync, validateReceiptIos } from './modules/ios';
3
- import { validateReceiptAndroid } from './modules/android';
1
+ // External dependencies
4
2
  import { useCallback, useEffect, useState, useRef } from 'react';
5
3
  import { Platform } from 'react-native';
4
+ // Internal modules
5
+ import { endConnection, initConnection, purchaseErrorListener, purchaseUpdatedListener, getProducts, getAvailablePurchases, getPurchaseHistories, finishTransaction as finishTransactionInternal, getSubscriptions, requestPurchase as requestPurchaseInternal, } from './';
6
+ import { syncIOS, validateReceiptIOS } from './modules/ios';
7
+ import { validateReceiptAndroid } from './modules/android';
6
8
  export function useIAP(options) {
7
9
  const [connected, setConnected] = useState(false);
8
10
  const [products, setProducts] = useState([]);
@@ -116,7 +118,7 @@ export function useIAP(options) {
116
118
  const restorePurchases = useCallback(async () => {
117
119
  try {
118
120
  if (Platform.OS === 'ios') {
119
- await sync().catch((error) => {
121
+ await syncIOS().catch((error) => {
120
122
  if (optionsRef.current?.onSyncError) {
121
123
  optionsRef.current.onSyncError(error);
122
124
  }
@@ -133,7 +135,7 @@ export function useIAP(options) {
133
135
  }, [getAvailablePurchasesInternal]);
134
136
  const validateReceipt = useCallback(async (sku, androidOptions) => {
135
137
  if (Platform.OS === 'ios') {
136
- return await validateReceiptIos(sku);
138
+ return await validateReceiptIOS(sku);
137
139
  }
138
140
  else if (Platform.OS === 'android') {
139
141
  if (!androidOptions ||