expo-iap 2.8.7 → 2.8.8
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 +23 -0
- package/CLAUDE.md +7 -0
- package/build/helpers/subscription.d.ts +3 -0
- package/build/helpers/subscription.d.ts.map +1 -1
- package/build/helpers/subscription.js +3 -0
- package/build/helpers/subscription.js.map +1 -1
- package/build/modules/ios.d.ts +4 -5
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +2 -3
- package/build/modules/ios.js.map +1 -1
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +4 -1
- package/build/useIAP.js.map +1 -1
- package/build/utils/constants.d.ts +4 -0
- package/build/utils/constants.d.ts.map +1 -0
- package/build/utils/constants.js +12 -0
- package/build/utils/constants.js.map +1 -0
- package/ios/ExpoIapModule.swift +80 -150
- package/package.json +3 -2
- package/src/helpers/subscription.ts +6 -0
- package/src/modules/ios.ts +4 -5
- package/src/useIAP.ts +4 -1
- package/src/utils/constants.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## [2.8.8] - 2025-09-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Enhanced `ActiveSubscription` interface with backend validation fields:
|
|
8
|
+
- `transactionId` - Transaction identifier for backend validation
|
|
9
|
+
- `purchaseToken` - JWT token (iOS) or purchase token (Android) for backend validation
|
|
10
|
+
- `transactionDate` - Transaction timestamp
|
|
11
|
+
- Return subscription changes from `showManageSubscriptionsIOS()` as Promise data
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Fixed iOS `getAvailablePurchases({ onlyIncludeActiveItemsIOS: true })` returning expired subscriptions
|
|
16
|
+
- Now correctly uses `Transaction.currentEntitlements` for better performance and accuracy
|
|
17
|
+
- Fixed subscription status matching to specific SKU in `showManageSubscriptionsIOS()`
|
|
18
|
+
- Prevents picking wrong status when multiple statuses exist in a subscription group
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Removed unnecessary event sending from `getAvailableItems()` - events are only sent from `requestPurchase()`
|
|
23
|
+
- Removed polling logic from subscription status monitoring for cleaner code
|
|
24
|
+
- Updated to comply with OpenIAP v1.1.1 specification
|
|
25
|
+
|
|
3
26
|
## [2.8.7] - 2025-09-03
|
|
4
27
|
|
|
5
28
|
### Added
|
package/CLAUDE.md
CHANGED
|
@@ -93,3 +93,10 @@ For new feature proposals:
|
|
|
93
93
|
2. Get community feedback and consensus
|
|
94
94
|
3. Ensure alignment with OpenIAP standards
|
|
95
95
|
4. Implement following the agreed specification
|
|
96
|
+
|
|
97
|
+
## Documentation Guidelines
|
|
98
|
+
|
|
99
|
+
### Blog Post Conventions
|
|
100
|
+
|
|
101
|
+
- **Title format**: Use version number only (e.g., `v2.8.7 - Feature Description`, not `Expo IAP v2.8.7 - Feature Description`)
|
|
102
|
+
- **Heading format**: Use version number only in headings (e.g., `# v2.8.7 Release Notes`, not `# Expo IAP v2.8.7 Release Notes`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,kBAAkB,EAAE,CAmG9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,OAAO,CAGjB,CAAC"}
|
|
@@ -56,6 +56,9 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
|
|
|
56
56
|
const subscription = {
|
|
57
57
|
productId: purchase.productId,
|
|
58
58
|
isActive: true,
|
|
59
|
+
transactionId: purchase.transactionId || purchase.id,
|
|
60
|
+
purchaseToken: purchase.purchaseToken,
|
|
61
|
+
transactionDate: purchase.transactionDate,
|
|
59
62
|
};
|
|
60
63
|
// Add platform-specific details
|
|
61
64
|
if (Platform.OS === 'ios') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],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QAAQ,CAAC,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CACnE,CAAC;oBACF,YAAY,CAAC,sBAAsB,GAAG,mBAAmB,CAAC;oBAC1D,YAAY,CAAC,cAAc,GAAG,mBAAmB,IAAI,CAAC,CAAC;gBACzD,CAAC;gBAED,IAAI,gBAAgB,IAAI,QAAQ,EAAE,CAAC;oBACjC,YAAY,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;gBACxD,CAAC;YACH,CAAC;iBAAM,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;gBACrC,IAAI,qBAAqB,IAAI,QAAQ,EAAE,CAAC;oBACtC,YAAY,CAAC,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC;oBAChE,2DAA2D;oBAC3D,YAAY,CAAC,cAAc,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC;gBAC9D,CAAC;YACH,CAAC;YAED,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,eAA0B,EACR,EAAE;IACpB,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC,eAAe,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {getAvailablePurchases} from '../index';\n\nexport interface ActiveSubscription {\n productId: string;\n isActive: boolean;\n transactionId: string; // Transaction identifier for backend validation\n purchaseToken?: string; // JWT token (iOS) or purchase token (Android) for backend validation\n transactionDate: number; // Transaction timestamp\n expirationDateIOS?: Date;\n autoRenewingAndroid?: boolean;\n environmentIOS?: string;\n willExpireSoon?: boolean;\n daysUntilExpirationIOS?: number;\n}\n\n/**\n * Get all active subscriptions with detailed information\n * @param subscriptionIds - Optional array of subscription product IDs to filter. If not provided, returns all active subscriptions.\n * @returns Promise<ActiveSubscription[]> array of active subscriptions with details\n */\nexport const getActiveSubscriptions = async (\n subscriptionIds?: string[],\n): Promise<ActiveSubscription[]> => {\n try {\n const purchases = await getAvailablePurchases();\n const currentTime = Date.now();\n const activeSubscriptions: ActiveSubscription[] = [];\n\n // Filter purchases to find active subscriptions\n const filteredPurchases = purchases.filter((purchase) => {\n // If specific IDs provided, filter by them\n if (subscriptionIds && subscriptionIds.length > 0) {\n if (!subscriptionIds.includes(purchase.productId)) {\n return false;\n }\n }\n\n // Check if this purchase has subscription-specific fields\n const hasSubscriptionFields =\n ('expirationDateIOS' in purchase && purchase.expirationDateIOS) ||\n 'autoRenewingAndroid' in purchase ||\n ('environmentIOS' in purchase && purchase.environmentIOS === 'Sandbox');\n\n if (!hasSubscriptionFields) {\n return false;\n }\n\n // Check if it's actually active\n if (Platform.OS === 'ios') {\n if ('expirationDateIOS' in purchase && purchase.expirationDateIOS) {\n return purchase.expirationDateIOS > currentTime;\n }\n // For iOS purchases without expiration date (like Sandbox), we consider them active\n // if they have the environmentIOS field and were created recently\n if ('environmentIOS' in purchase && purchase.environmentIOS) {\n const dayInMs = 24 * 60 * 60 * 1000;\n // If no expiration date, consider active if transaction is recent (within 24 hours for Sandbox)\n if (\n !('expirationDateIOS' in purchase) ||\n !purchase.expirationDateIOS\n ) {\n if (\n purchase.environmentIOS === 'Sandbox' &&\n purchase.transactionDate &&\n currentTime - purchase.transactionDate < dayInMs\n ) {\n return true;\n }\n }\n }\n } else if (Platform.OS === 'android') {\n // For Android, if it's in the purchases list, it's active\n return true;\n }\n\n return false;\n });\n\n // Convert to ActiveSubscription format\n for (const purchase of filteredPurchases) {\n const subscription: ActiveSubscription = {\n productId: purchase.productId,\n isActive: true,\n transactionId: purchase.transactionId || purchase.id,\n purchaseToken: purchase.purchaseToken,\n transactionDate: purchase.transactionDate,\n };\n\n // Add platform-specific details\n if (Platform.OS === 'ios') {\n if ('expirationDateIOS' in purchase && purchase.expirationDateIOS) {\n const expirationDate = new Date(purchase.expirationDateIOS);\n subscription.expirationDateIOS = expirationDate;\n\n // Calculate days until expiration (round to nearest day)\n const daysUntilExpiration = Math.round(\n (purchase.expirationDateIOS - currentTime) / (1000 * 60 * 60 * 24),\n );\n subscription.daysUntilExpirationIOS = daysUntilExpiration;\n subscription.willExpireSoon = daysUntilExpiration <= 7;\n }\n\n if ('environmentIOS' in purchase) {\n subscription.environmentIOS = purchase.environmentIOS;\n }\n } else if (Platform.OS === 'android') {\n if ('autoRenewingAndroid' in purchase) {\n subscription.autoRenewingAndroid = purchase.autoRenewingAndroid;\n // If auto-renewing is false, subscription will expire soon\n subscription.willExpireSoon = !purchase.autoRenewingAndroid;\n }\n }\n\n activeSubscriptions.push(subscription);\n }\n\n return activeSubscriptions;\n } catch (error) {\n console.error('Error getting active subscriptions:', error);\n return [];\n }\n};\n\n/**\n * Check if user has any active subscriptions\n * @param subscriptionIds - Optional array of subscription product IDs to check. If not provided, checks all subscriptions.\n * @returns Promise<boolean> true if user has at least one active subscription\n */\nexport const hasActiveSubscriptions = async (\n subscriptionIds?: string[],\n): Promise<boolean> => {\n const subscriptions = await getActiveSubscriptions(subscriptionIds);\n return subscriptions.length > 0;\n};\n"]}
|
package/build/modules/ios.d.ts
CHANGED
|
@@ -88,15 +88,14 @@ type RefundRequestStatus = 'success' | 'userCancelled';
|
|
|
88
88
|
export declare const beginRefundRequestIOS: (sku: string) => Promise<RefundRequestStatus>;
|
|
89
89
|
/**
|
|
90
90
|
* Shows the system UI for managing subscriptions.
|
|
91
|
-
*
|
|
92
|
-
* purchaseUpdatedListener and transactionUpdatedIOS listeners.
|
|
91
|
+
* Returns an array of subscriptions that had status changes after the UI is closed.
|
|
93
92
|
*
|
|
94
|
-
* @returns Promise
|
|
93
|
+
* @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)
|
|
95
94
|
* @throws Error if called on non-iOS platform
|
|
96
95
|
*
|
|
97
96
|
* @platform iOS
|
|
98
97
|
*/
|
|
99
|
-
export declare const showManageSubscriptionsIOS: () => Promise<
|
|
98
|
+
export declare const showManageSubscriptionsIOS: () => Promise<Purchase[]>;
|
|
100
99
|
/**
|
|
101
100
|
* Get the receipt data from the iOS device.
|
|
102
101
|
* This returns the base64 encoded receipt data which can be sent to your server
|
|
@@ -251,7 +250,7 @@ export declare const beginRefundRequest: (sku: string) => Promise<RefundRequestS
|
|
|
251
250
|
/**
|
|
252
251
|
* @deprecated Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.
|
|
253
252
|
*/
|
|
254
|
-
export declare const showManageSubscriptions: () => Promise<
|
|
253
|
+
export declare const showManageSubscriptions: () => Promise<Purchase[]>;
|
|
255
254
|
/**
|
|
256
255
|
* @deprecated Use `isTransactionVerifiedIOS` instead. This function will be removed in version 3.0.0.
|
|
257
256
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAGnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAGF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI;;CAkC5C,CAAC;AAGF,wBAAg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O,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,QAAQ,CAKhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,QAAQ,CAK/D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,KAAK,MAAM,KACV,OAAO,CAAC,mBAAmB,CAK7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAO,OAAO,CAAC,QAAQ,EAAE,CAK5D,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,0BAA0B,QAAO,OAAO,CAAC,OAAO,CAK5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAKpE,CAAC"}
|
package/build/modules/ios.js
CHANGED
|
@@ -117,10 +117,9 @@ export const beginRefundRequestIOS = (sku) => {
|
|
|
117
117
|
};
|
|
118
118
|
/**
|
|
119
119
|
* Shows the system UI for managing subscriptions.
|
|
120
|
-
*
|
|
121
|
-
* purchaseUpdatedListener and transactionUpdatedIOS listeners.
|
|
120
|
+
* Returns an array of subscriptions that had status changes after the UI is closed.
|
|
122
121
|
*
|
|
123
|
-
* @returns Promise
|
|
122
|
+
* @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)
|
|
124
123
|
* @throws Error if called on non-iOS platform
|
|
125
124
|
*
|
|
126
125
|
* @platform iOS
|
package/build/modules/ios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"m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ChC,OAAO,CAAC,IAAI,CACV,0HAA0H,CAC3H,CAAC;IACF,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAkB,EAAE;IACzD,OAAO,CAAC,IAAI,CACV,oIAAoI,CACrI,CAAC;IACF,OAAO,0BAA0B,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,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,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\n\n// Internal modules\nimport {purchaseUpdatedListener} from '..';\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport {Product, Purchase, PurchaseError} from '../ExpoIap.types';\nimport type {\n ProductStatusIOS,\n AppTransactionIOS,\n} from '../types/ExpoIapIOS.types';\nimport {Linking} from 'react-native';\n\nexport type TransactionEvent = {\n transaction?: Purchase;\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 const isPurchase = (item: unknown): item is Purchase => {\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,\n ): TransactionEvent => {\n // Validate the purchase object before casting\n if (isPurchase(purchase)) {\n return {\n transaction: purchase as Purchase,\n };\n }\n\n // Fallback: create a basic TransactionEvent structure\n return {\n transaction: purchase as Purchase,\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 return ExpoIapModule.syncIOS();\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 return ExpoIapModule.isEligibleForIntroOfferIOS(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 return ExpoIapModule.subscriptionStatusIOS(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 = (sku: string): Promise<Purchase> => {\n return ExpoIapModule.currentEntitlementIOS(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<Purchase> => {\n return ExpoIapModule.latestTransactionIOS(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 return ExpoIapModule.beginRefundRequestIOS(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 return ExpoIapModule.showManageSubscriptionsIOS();\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 return ExpoIapModule.getReceiptDataIOS();\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 return ExpoIapModule.isTransactionVerifiedIOS(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 return ExpoIapModule.getTransactionJwsIOS(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?: Purchase;\n * }>}\n */\nexport const validateReceiptIOS = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: Purchase;\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 return ExpoIapModule.presentCodeRedemptionSheetIOS();\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n */\nexport const getAppTransactionIOS = (): Promise<AppTransactionIOS | null> => {\n return ExpoIapModule.getAppTransactionIOS();\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> => {\n return ExpoIapModule.getPromotedProductIOS();\n};\n\n/**\n * Complete the purchase of a promoted product (iOS only).\n * This should be called after showing your purchase UI for a promoted product.\n *\n * @returns Promise resolving when the purchase is initiated\n * @throws Error if called on non-iOS platform or no promoted product is available\n *\n * @platform iOS\n */\nexport const requestPurchaseOnPromotedProductIOS = (): Promise<void> => {\n return ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n};\n\n/**\n * @deprecated Use requestPurchaseOnPromotedProductIOS instead. Will be removed in v2.9.0\n */\nexport const buyPromotedProductIOS = (): Promise<void> => {\n return requestPurchaseOnPromotedProductIOS();\n};\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n */\nexport const getPendingTransactionsIOS = (): Promise<any[]> => {\n return ExpoIapModule.getPendingTransactionsIOS();\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n */\nexport const clearTransactionIOS = (): Promise<void> => {\n return ExpoIapModule.clearTransactionIOS();\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\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<Purchase> => {\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<Purchase> => {\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 `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 `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
|
+
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,OAAO,EAAC,uBAAuB,EAAC,MAAM,IAAI,CAAC;AAC3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAQ7C,OAAO,EAA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M,uBAAuB,GAAG,GAAwB,EAAE;IAC/D,OAAO,CAAC,IAAI,CACV,oIAAoI,CACrI,CAAC;IACF,OAAO,0BAA0B,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,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,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\n\n// Internal modules\nimport {purchaseUpdatedListener} from '..';\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport {Product, Purchase, PurchaseError} from '../ExpoIap.types';\nimport type {\n ProductStatusIOS,\n AppTransactionIOS,\n} from '../types/ExpoIapIOS.types';\nimport {Linking} from 'react-native';\n\nexport type TransactionEvent = {\n transaction?: Purchase;\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 const isPurchase = (item: unknown): item is Purchase => {\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,\n ): TransactionEvent => {\n // Validate the purchase object before casting\n if (isPurchase(purchase)) {\n return {\n transaction: purchase as Purchase,\n };\n }\n\n // Fallback: create a basic TransactionEvent structure\n return {\n transaction: purchase as Purchase,\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 return ExpoIapModule.syncIOS();\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 return ExpoIapModule.isEligibleForIntroOfferIOS(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 return ExpoIapModule.subscriptionStatusIOS(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 = (sku: string): Promise<Purchase> => {\n return ExpoIapModule.currentEntitlementIOS(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<Purchase> => {\n return ExpoIapModule.latestTransactionIOS(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 return ExpoIapModule.beginRefundRequestIOS(sku);\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const showManageSubscriptionsIOS = (): Promise<Purchase[]> => {\n return ExpoIapModule.showManageSubscriptionsIOS();\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 return ExpoIapModule.getReceiptDataIOS();\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 return ExpoIapModule.isTransactionVerifiedIOS(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 return ExpoIapModule.getTransactionJwsIOS(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?: Purchase;\n * }>}\n */\nexport const validateReceiptIOS = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: Purchase;\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 return ExpoIapModule.presentCodeRedemptionSheetIOS();\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n */\nexport const getAppTransactionIOS = (): Promise<AppTransactionIOS | null> => {\n return ExpoIapModule.getAppTransactionIOS();\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> => {\n return ExpoIapModule.getPromotedProductIOS();\n};\n\n/**\n * Complete the purchase of a promoted product (iOS only).\n * This should be called after showing your purchase UI for a promoted product.\n *\n * @returns Promise resolving when the purchase is initiated\n * @throws Error if called on non-iOS platform or no promoted product is available\n *\n * @platform iOS\n */\nexport const requestPurchaseOnPromotedProductIOS = (): Promise<void> => {\n return ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n};\n\n/**\n * @deprecated Use requestPurchaseOnPromotedProductIOS instead. Will be removed in v2.9.0\n */\nexport const buyPromotedProductIOS = (): Promise<void> => {\n return requestPurchaseOnPromotedProductIOS();\n};\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n */\nexport const getPendingTransactionsIOS = (): Promise<any[]> => {\n return ExpoIapModule.getPendingTransactionsIOS();\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n */\nexport const clearTransactionIOS = (): Promise<void> => {\n return ExpoIapModule.clearTransactionIOS();\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\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<Purchase> => {\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<Purchase> => {\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<Purchase[]> => {\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 `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 `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"]}
|
package/build/useIAP.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIAP.d.ts","sourceRoot":"","sources":["../src/useIAP.ts"],"names":[],"mappings":"AAMA,OAAO,EAcL,KAAK,kBAAkB,EACxB,MAAM,GAAG,CAAC;AAQX,OAAO,EACL,OAAO,EACP,QAAQ,EACR,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,KAAK,MAAM,GAAG;IACZ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CAAC;IACzD,kEAAkE;IAClE,qBAAqB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,sBAAsB,EAAE,CACtB,eAAe,CAAC,EAAE,MAAM,EAAE,KACvB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACnC,sBAAsB,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1E,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACjD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAqXtD"}
|
package/build/useIAP.js
CHANGED
|
@@ -84,7 +84,10 @@ export function useIAP(options) {
|
|
|
84
84
|
}, [fetchProductsInternal]);
|
|
85
85
|
const getAvailablePurchasesInternal = useCallback(async () => {
|
|
86
86
|
try {
|
|
87
|
-
const result = await getAvailablePurchases(
|
|
87
|
+
const result = await getAvailablePurchases({
|
|
88
|
+
alsoPublishToEventListenerIOS: false,
|
|
89
|
+
onlyIncludeActiveItemsIOS: true,
|
|
90
|
+
});
|
|
88
91
|
setAvailablePurchases(result);
|
|
89
92
|
}
|
|
90
93
|
catch (error) {
|
package/build/useIAP.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIAP.js","sourceRoot":"","sources":["../src/useIAP.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,WAAW,EAAE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QACR,mBAAmB;QACnB,oBAAoB;QACpB,aAAa;QACb,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,eAAe;QACf,oBAAoB;QACpB,kBAAkB;QAClB,mBAAmB;QACnB,oBAAoB;QACpB,yBAAyB;QACzB,qBAAqB,EAAE,6BAA6B;QACpD,oBAAoB,EAAE,4BAA4B;QAClD,aAAa,EAAE,qBAAqB;QACpC,eAAe,EAAE,uBAAuB;QACxC,eAAe,EAAE,wBAAwB;QACzC,eAAe;QACf,gBAAgB;QAChB,WAAW,EAAE,mBAAmB;QAChC,gBAAgB,EAAE,wBAAwB;QAC1C,qBAAqB;QACrB,mCAAmC;QACnC,qBAAqB,EAAE,mCAAmC,EAAE,mBAAmB;QAC/E,sBAAsB,EAAE,8BAA8B;QACtD,sBAAsB,EAAE,8BAA8B;KACvD,CAAC;AACJ,CAAC","sourcesContent":["// External dependencies\nimport {useCallback, useEffect, useState, useRef} from 'react';\nimport {Platform} from 'react-native';\nimport {EventSubscription} from 'expo-modules-core';\n\n// Internal modules\nimport {\n endConnection,\n initConnection,\n purchaseErrorListener,\n purchaseUpdatedListener,\n promotedProductListenerIOS,\n getAvailablePurchases,\n getPurchaseHistories,\n finishTransaction as finishTransactionInternal,\n requestPurchase as requestPurchaseInternal,\n fetchProducts,\n validateReceipt as validateReceiptInternal,\n getActiveSubscriptions,\n hasActiveSubscriptions,\n type ActiveSubscription,\n} from '.';\nimport {\n syncIOS,\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n} from './modules/ios';\n\n// Types\nimport {\n Product,\n Purchase,\n PurchaseError,\n PurchaseResult,\n SubscriptionProduct,\n RequestPurchaseProps,\n RequestSubscriptionProps,\n} from './ExpoIap.types';\n\ntype UseIap = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Purchase[];\n promotedProductIdIOS?: string;\n subscriptions: SubscriptionProduct[];\n purchaseHistories: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n promotedProductIOS?: Product;\n activeSubscriptions: ActiveSubscription[];\n clearCurrentPurchase: () => void;\n clearCurrentPurchaseError: () => void;\n finishTransaction: ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }) => Promise<PurchaseResult | boolean>;\n getAvailablePurchases: (skus: string[]) => Promise<void>;\n getPurchaseHistories: (skus: string[]) => Promise<void>;\n fetchProducts: (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }) => Promise<void>;\n /**\n * @deprecated Use fetchProducts({ skus, type: 'inapp' | 'subs' }) instead. This method will be removed in version 3.0.0.\n * The 'request' prefix should only be used for event-based operations.\n */\n requestProducts: (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }) => Promise<void>;\n /**\n * @deprecated Use fetchProducts({ skus, type: 'inapp' }) instead. This method will be removed in version 3.0.0.\n * Note: This method internally uses fetchProducts, so no deprecation warning is shown.\n */\n getProducts: (skus: string[]) => Promise<void>;\n /**\n * @deprecated Use fetchProducts({ skus, type: 'subs' }) instead. This method will be removed in version 3.0.0.\n * Note: This method internally uses fetchProducts, so no deprecation warning is shown.\n */\n getSubscriptions: (skus: string[]) => Promise<void>;\n requestPurchase: (params: {\n request: RequestPurchaseProps | RequestSubscriptionProps;\n type?: 'inapp' | 'subs';\n }) => Promise<any>;\n validateReceipt: (\n sku: string,\n androidOptions?: {\n packageName: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n },\n ) => Promise<any>;\n restorePurchases: () => Promise<void>;\n getPromotedProductIOS: () => Promise<Product | null>;\n requestPurchaseOnPromotedProductIOS: () => Promise<void>;\n /** @deprecated Use requestPurchaseOnPromotedProductIOS instead */\n buyPromotedProductIOS: () => Promise<void>;\n getActiveSubscriptions: (\n subscriptionIds?: string[],\n ) => Promise<ActiveSubscription[]>;\n hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;\n};\n\nexport interface UseIAPOptions {\n onPurchaseSuccess?: (purchase: Purchase) => void;\n onPurchaseError?: (error: PurchaseError) => void;\n onSyncError?: (error: Error) => void;\n shouldAutoSyncPurchases?: boolean; // New option to control auto-syncing\n onPromotedProductIOS?: (product: Product) => void;\n}\n\n/**\n * React Hook for managing In-App Purchases.\n * See documentation at https://expo-iap.hyo.dev/docs/hooks/useIAP\n */\nexport function useIAP(options?: UseIAPOptions): UseIap {\n const [connected, setConnected] = useState<boolean>(false);\n const [products, setProducts] = useState<Product[]>([]);\n const [promotedProductsIOS] = useState<Purchase[]>([]);\n const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);\n const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>([]);\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n const [promotedProductIdIOS] = useState<string>();\n const [activeSubscriptions, setActiveSubscriptions] = useState<\n ActiveSubscription[]\n >([]);\n\n const optionsRef = useRef<UseIAPOptions | undefined>(options);\n\n // Helper function to merge arrays with duplicate checking\n const mergeWithDuplicateCheck = useCallback(\n <T>(\n existingItems: T[],\n newItems: T[],\n getKey: (item: T) => string,\n ): T[] => {\n const merged = [...existingItems];\n newItems.forEach((newItem) => {\n const isDuplicate = merged.some(\n (existingItem) => getKey(existingItem) === getKey(newItem),\n );\n if (!isDuplicate) {\n merged.push(newItem);\n }\n });\n return merged;\n },\n [],\n );\n\n useEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n const subscriptionsRef = useRef<{\n purchaseUpdate?: EventSubscription;\n purchaseError?: EventSubscription;\n promotedProductsIOS?: EventSubscription;\n promotedProductIOS?: EventSubscription;\n }>({});\n\n const subscriptionsRefState = useRef<SubscriptionProduct[]>([]);\n\n useEffect(() => {\n subscriptionsRefState.current = subscriptions;\n }, [subscriptions]);\n\n const clearCurrentPurchase = useCallback(() => {\n setCurrentPurchase(undefined);\n }, []);\n\n const clearCurrentPurchaseError = useCallback(() => {\n setCurrentPurchaseError(undefined);\n }, []);\n\n const getProductsInternal = useCallback(\n async (skus: string[]): Promise<void> => {\n try {\n const result = await fetchProducts({skus, type: 'inapp'});\n setProducts((prevProducts) =>\n mergeWithDuplicateCheck(\n prevProducts,\n result as Product[],\n (product) => product.id,\n ),\n );\n } catch (error) {\n console.error('Error fetching products:', error);\n }\n },\n [mergeWithDuplicateCheck],\n );\n\n const getSubscriptionsInternal = useCallback(\n async (skus: string[]): Promise<void> => {\n try {\n const result = await fetchProducts({skus, type: 'subs'});\n setSubscriptions((prevSubscriptions) =>\n mergeWithDuplicateCheck(\n prevSubscriptions,\n result as SubscriptionProduct[],\n (subscription) => subscription.id,\n ),\n );\n } catch (error) {\n console.error('Error fetching subscriptions:', error);\n }\n },\n [mergeWithDuplicateCheck],\n );\n\n const fetchProductsInternal = useCallback(\n async (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }): Promise<void> => {\n try {\n const result = await fetchProducts(params);\n if (params.type === 'subs') {\n setSubscriptions((prevSubscriptions) =>\n mergeWithDuplicateCheck(\n prevSubscriptions,\n result as SubscriptionProduct[],\n (subscription) => subscription.id,\n ),\n );\n } else {\n setProducts((prevProducts) =>\n mergeWithDuplicateCheck(\n prevProducts,\n result as Product[],\n (product) => product.id,\n ),\n );\n }\n } catch (error) {\n console.error('Error fetching products:', error);\n }\n },\n [mergeWithDuplicateCheck],\n );\n\n const requestProductsInternal = useCallback(\n async (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }): Promise<void> => {\n console.warn(\n \"`requestProducts` is deprecated in useIAP hook. Use the new `fetchProducts` method instead. The 'request' prefix should only be used for event-based operations.\",\n );\n return fetchProductsInternal(params);\n },\n [fetchProductsInternal],\n );\n\n const getAvailablePurchasesInternal = useCallback(async (): Promise<void> => {\n try {\n const result = await getAvailablePurchases();\n setAvailablePurchases(result);\n } catch (error) {\n console.error('Error fetching available purchases:', error);\n }\n }, []);\n\n const getActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<ActiveSubscription[]> => {\n try {\n const result = await getActiveSubscriptions(subscriptionIds);\n setActiveSubscriptions(result);\n return result;\n } catch (error) {\n console.error('Error getting active subscriptions:', error);\n // Don't clear existing activeSubscriptions on error - preserve current state\n // This prevents the UI from showing empty state when there are temporary network issues\n return [];\n }\n },\n [],\n );\n\n const hasActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<boolean> => {\n try {\n return await hasActiveSubscriptions(subscriptionIds);\n } catch (error) {\n console.error('Error checking active subscriptions:', error);\n return false;\n }\n },\n [],\n );\n\n /**\n * @deprecated Use getAvailablePurchases instead. This function is just calling getAvailablePurchases internally.\n * Will be removed in v2.9.0\n */\n const getPurchaseHistoriesInternal = useCallback(async (): Promise<void> => {\n setPurchaseHistories(await getPurchaseHistories());\n }, []);\n\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }): Promise<PurchaseResult | boolean> => {\n try {\n return await finishTransactionInternal({\n purchase,\n isConsumable,\n });\n } catch (err) {\n throw err;\n } finally {\n if (purchase.id === currentPurchase?.id) {\n clearCurrentPurchase();\n }\n if (purchase.id === currentPurchaseError?.productId) {\n clearCurrentPurchaseError();\n }\n }\n },\n [\n currentPurchase?.id,\n currentPurchaseError?.productId,\n clearCurrentPurchase,\n clearCurrentPurchaseError,\n ],\n );\n\n const requestPurchaseWithReset = useCallback(\n async (requestObj: {request: any; type?: 'inapp' | 'subs'}) => {\n clearCurrentPurchase();\n clearCurrentPurchaseError();\n\n try {\n return await requestPurchaseInternal(requestObj);\n } catch (error) {\n throw error;\n }\n },\n [clearCurrentPurchase, clearCurrentPurchaseError],\n );\n\n const refreshSubscriptionStatus = useCallback(\n async (productId: string) => {\n try {\n if (subscriptionsRefState.current.some((sub) => sub.id === productId)) {\n await getSubscriptionsInternal([productId]);\n await getAvailablePurchasesInternal();\n }\n } catch (error) {\n console.warn('Failed to refresh subscription status:', error);\n }\n },\n [getAvailablePurchasesInternal, getSubscriptionsInternal],\n );\n\n const restorePurchases = useCallback(async (): Promise<void> => {\n try {\n if (Platform.OS === 'ios') {\n await syncIOS().catch((error) => {\n if (optionsRef.current?.onSyncError) {\n optionsRef.current.onSyncError(error);\n } else {\n console.warn('Error restoring purchases:', error);\n }\n });\n }\n await getAvailablePurchasesInternal();\n } catch (error) {\n console.warn('Failed to restore purchases:', error);\n }\n }, [getAvailablePurchasesInternal]);\n\n const validateReceipt = useCallback(\n async (\n sku: string,\n androidOptions?: {\n packageName: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n },\n ) => {\n return validateReceiptInternal(sku, androidOptions);\n },\n [],\n );\n\n const initIapWithSubscriptions = useCallback(async (): Promise<void> => {\n const result = await initConnection();\n setConnected(result);\n\n if (result) {\n subscriptionsRef.current.purchaseUpdate = purchaseUpdatedListener(\n async (purchase: Purchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n\n if ('expirationDateIOS' in purchase) {\n await refreshSubscriptionStatus(purchase.id);\n }\n\n if (optionsRef.current?.onPurchaseSuccess) {\n optionsRef.current.onPurchaseSuccess(purchase);\n }\n },\n );\n\n subscriptionsRef.current.purchaseError = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n\n if (optionsRef.current?.onPurchaseError) {\n optionsRef.current.onPurchaseError(error);\n }\n },\n );\n\n if (Platform.OS === 'ios') {\n // iOS promoted products listener\n subscriptionsRef.current.promotedProductsIOS =\n promotedProductListenerIOS((product: Product) => {\n setPromotedProductIOS(product);\n\n if (optionsRef.current?.onPromotedProductIOS) {\n optionsRef.current.onPromotedProductIOS(product);\n }\n });\n }\n }\n }, [refreshSubscriptionStatus]);\n\n useEffect(() => {\n initIapWithSubscriptions();\n const currentSubscriptions = subscriptionsRef.current;\n\n return () => {\n currentSubscriptions.purchaseUpdate?.remove();\n currentSubscriptions.purchaseError?.remove();\n currentSubscriptions.promotedProductsIOS?.remove();\n currentSubscriptions.promotedProductIOS?.remove();\n endConnection();\n setConnected(false);\n };\n }, [initIapWithSubscriptions]);\n\n return {\n connected,\n products,\n promotedProductsIOS,\n promotedProductIdIOS,\n subscriptions,\n purchaseHistories,\n finishTransaction,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n promotedProductIOS,\n activeSubscriptions,\n clearCurrentPurchase,\n clearCurrentPurchaseError,\n getAvailablePurchases: getAvailablePurchasesInternal,\n getPurchaseHistories: getPurchaseHistoriesInternal,\n fetchProducts: fetchProductsInternal,\n requestProducts: requestProductsInternal,\n requestPurchase: requestPurchaseWithReset,\n validateReceipt,\n restorePurchases,\n getProducts: getProductsInternal,\n getSubscriptions: getSubscriptionsInternal,\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n buyPromotedProductIOS: requestPurchaseOnPromotedProductIOS, // deprecated alias\n getActiveSubscriptions: getActiveSubscriptionsInternal,\n hasActiveSubscriptions: hasActiveSubscriptionsInternal,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useIAP.js","sourceRoot":"","sources":["../src/useIAP.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAGtC,mBAAmB;AACnB,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,IAAI,yBAAyB,EAC9C,eAAe,IAAI,uBAAuB,EAC1C,aAAa,EACb,eAAe,IAAI,uBAAuB,EAC1C,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,GAAG,CAAC;AACX,OAAO,EACL,OAAO,EACP,qBAAqB,EACrB,mCA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,gBAAgB,EAAE,wBAAwB;QAC1C,qBAAqB;QACrB,mCAAmC;QACnC,qBAAqB,EAAE,mCAAmC,EAAE,mBAAmB;QAC/E,sBAAsB,EAAE,8BAA8B;QACtD,sBAAsB,EAAE,8BAA8B;KACvD,CAAC;AACJ,CAAC","sourcesContent":["// External dependencies\nimport {useCallback, useEffect, useState, useRef} from 'react';\nimport {Platform} from 'react-native';\nimport {EventSubscription} from 'expo-modules-core';\n\n// Internal modules\nimport {\n endConnection,\n initConnection,\n purchaseErrorListener,\n purchaseUpdatedListener,\n promotedProductListenerIOS,\n getAvailablePurchases,\n getPurchaseHistories,\n finishTransaction as finishTransactionInternal,\n requestPurchase as requestPurchaseInternal,\n fetchProducts,\n validateReceipt as validateReceiptInternal,\n getActiveSubscriptions,\n hasActiveSubscriptions,\n type ActiveSubscription,\n} from '.';\nimport {\n syncIOS,\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n} from './modules/ios';\n\n// Types\nimport {\n Product,\n Purchase,\n PurchaseError,\n PurchaseResult,\n SubscriptionProduct,\n RequestPurchaseProps,\n RequestSubscriptionProps,\n} from './ExpoIap.types';\n\ntype UseIap = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Purchase[];\n promotedProductIdIOS?: string;\n subscriptions: SubscriptionProduct[];\n purchaseHistories: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n promotedProductIOS?: Product;\n activeSubscriptions: ActiveSubscription[];\n clearCurrentPurchase: () => void;\n clearCurrentPurchaseError: () => void;\n finishTransaction: ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }) => Promise<PurchaseResult | boolean>;\n getAvailablePurchases: (skus: string[]) => Promise<void>;\n getPurchaseHistories: (skus: string[]) => Promise<void>;\n fetchProducts: (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }) => Promise<void>;\n /**\n * @deprecated Use fetchProducts({ skus, type: 'inapp' | 'subs' }) instead. This method will be removed in version 3.0.0.\n * The 'request' prefix should only be used for event-based operations.\n */\n requestProducts: (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }) => Promise<void>;\n /**\n * @deprecated Use fetchProducts({ skus, type: 'inapp' }) instead. This method will be removed in version 3.0.0.\n * Note: This method internally uses fetchProducts, so no deprecation warning is shown.\n */\n getProducts: (skus: string[]) => Promise<void>;\n /**\n * @deprecated Use fetchProducts({ skus, type: 'subs' }) instead. This method will be removed in version 3.0.0.\n * Note: This method internally uses fetchProducts, so no deprecation warning is shown.\n */\n getSubscriptions: (skus: string[]) => Promise<void>;\n requestPurchase: (params: {\n request: RequestPurchaseProps | RequestSubscriptionProps;\n type?: 'inapp' | 'subs';\n }) => Promise<any>;\n validateReceipt: (\n sku: string,\n androidOptions?: {\n packageName: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n },\n ) => Promise<any>;\n restorePurchases: () => Promise<void>;\n getPromotedProductIOS: () => Promise<Product | null>;\n requestPurchaseOnPromotedProductIOS: () => Promise<void>;\n /** @deprecated Use requestPurchaseOnPromotedProductIOS instead */\n buyPromotedProductIOS: () => Promise<void>;\n getActiveSubscriptions: (\n subscriptionIds?: string[],\n ) => Promise<ActiveSubscription[]>;\n hasActiveSubscriptions: (subscriptionIds?: string[]) => Promise<boolean>;\n};\n\nexport interface UseIAPOptions {\n onPurchaseSuccess?: (purchase: Purchase) => void;\n onPurchaseError?: (error: PurchaseError) => void;\n onSyncError?: (error: Error) => void;\n shouldAutoSyncPurchases?: boolean; // New option to control auto-syncing\n onPromotedProductIOS?: (product: Product) => void;\n}\n\n/**\n * React Hook for managing In-App Purchases.\n * See documentation at https://expo-iap.hyo.dev/docs/hooks/useIAP\n */\nexport function useIAP(options?: UseIAPOptions): UseIap {\n const [connected, setConnected] = useState<boolean>(false);\n const [products, setProducts] = useState<Product[]>([]);\n const [promotedProductsIOS] = useState<Purchase[]>([]);\n const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);\n const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>([]);\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n const [promotedProductIdIOS] = useState<string>();\n const [activeSubscriptions, setActiveSubscriptions] = useState<\n ActiveSubscription[]\n >([]);\n\n const optionsRef = useRef<UseIAPOptions | undefined>(options);\n\n // Helper function to merge arrays with duplicate checking\n const mergeWithDuplicateCheck = useCallback(\n <T>(\n existingItems: T[],\n newItems: T[],\n getKey: (item: T) => string,\n ): T[] => {\n const merged = [...existingItems];\n newItems.forEach((newItem) => {\n const isDuplicate = merged.some(\n (existingItem) => getKey(existingItem) === getKey(newItem),\n );\n if (!isDuplicate) {\n merged.push(newItem);\n }\n });\n return merged;\n },\n [],\n );\n\n useEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n const subscriptionsRef = useRef<{\n purchaseUpdate?: EventSubscription;\n purchaseError?: EventSubscription;\n promotedProductsIOS?: EventSubscription;\n promotedProductIOS?: EventSubscription;\n }>({});\n\n const subscriptionsRefState = useRef<SubscriptionProduct[]>([]);\n\n useEffect(() => {\n subscriptionsRefState.current = subscriptions;\n }, [subscriptions]);\n\n const clearCurrentPurchase = useCallback(() => {\n setCurrentPurchase(undefined);\n }, []);\n\n const clearCurrentPurchaseError = useCallback(() => {\n setCurrentPurchaseError(undefined);\n }, []);\n\n const getProductsInternal = useCallback(\n async (skus: string[]): Promise<void> => {\n try {\n const result = await fetchProducts({skus, type: 'inapp'});\n setProducts((prevProducts) =>\n mergeWithDuplicateCheck(\n prevProducts,\n result as Product[],\n (product) => product.id,\n ),\n );\n } catch (error) {\n console.error('Error fetching products:', error);\n }\n },\n [mergeWithDuplicateCheck],\n );\n\n const getSubscriptionsInternal = useCallback(\n async (skus: string[]): Promise<void> => {\n try {\n const result = await fetchProducts({skus, type: 'subs'});\n setSubscriptions((prevSubscriptions) =>\n mergeWithDuplicateCheck(\n prevSubscriptions,\n result as SubscriptionProduct[],\n (subscription) => subscription.id,\n ),\n );\n } catch (error) {\n console.error('Error fetching subscriptions:', error);\n }\n },\n [mergeWithDuplicateCheck],\n );\n\n const fetchProductsInternal = useCallback(\n async (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }): Promise<void> => {\n try {\n const result = await fetchProducts(params);\n if (params.type === 'subs') {\n setSubscriptions((prevSubscriptions) =>\n mergeWithDuplicateCheck(\n prevSubscriptions,\n result as SubscriptionProduct[],\n (subscription) => subscription.id,\n ),\n );\n } else {\n setProducts((prevProducts) =>\n mergeWithDuplicateCheck(\n prevProducts,\n result as Product[],\n (product) => product.id,\n ),\n );\n }\n } catch (error) {\n console.error('Error fetching products:', error);\n }\n },\n [mergeWithDuplicateCheck],\n );\n\n const requestProductsInternal = useCallback(\n async (params: {\n skus: string[];\n type?: 'inapp' | 'subs';\n }): Promise<void> => {\n console.warn(\n \"`requestProducts` is deprecated in useIAP hook. Use the new `fetchProducts` method instead. The 'request' prefix should only be used for event-based operations.\",\n );\n return fetchProductsInternal(params);\n },\n [fetchProductsInternal],\n );\n\n const getAvailablePurchasesInternal = useCallback(async (): Promise<void> => {\n try {\n const result = await getAvailablePurchases({\n alsoPublishToEventListenerIOS: false,\n onlyIncludeActiveItemsIOS: true,\n });\n setAvailablePurchases(result);\n } catch (error) {\n console.error('Error fetching available purchases:', error);\n }\n }, []);\n\n const getActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<ActiveSubscription[]> => {\n try {\n const result = await getActiveSubscriptions(subscriptionIds);\n setActiveSubscriptions(result);\n return result;\n } catch (error) {\n console.error('Error getting active subscriptions:', error);\n // Don't clear existing activeSubscriptions on error - preserve current state\n // This prevents the UI from showing empty state when there are temporary network issues\n return [];\n }\n },\n [],\n );\n\n const hasActiveSubscriptionsInternal = useCallback(\n async (subscriptionIds?: string[]): Promise<boolean> => {\n try {\n return await hasActiveSubscriptions(subscriptionIds);\n } catch (error) {\n console.error('Error checking active subscriptions:', error);\n return false;\n }\n },\n [],\n );\n\n /**\n * @deprecated Use getAvailablePurchases instead. This function is just calling getAvailablePurchases internally.\n * Will be removed in v2.9.0\n */\n const getPurchaseHistoriesInternal = useCallback(async (): Promise<void> => {\n setPurchaseHistories(await getPurchaseHistories());\n }, []);\n\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n }): Promise<PurchaseResult | boolean> => {\n try {\n return await finishTransactionInternal({\n purchase,\n isConsumable,\n });\n } catch (err) {\n throw err;\n } finally {\n if (purchase.id === currentPurchase?.id) {\n clearCurrentPurchase();\n }\n if (purchase.id === currentPurchaseError?.productId) {\n clearCurrentPurchaseError();\n }\n }\n },\n [\n currentPurchase?.id,\n currentPurchaseError?.productId,\n clearCurrentPurchase,\n clearCurrentPurchaseError,\n ],\n );\n\n const requestPurchaseWithReset = useCallback(\n async (requestObj: {request: any; type?: 'inapp' | 'subs'}) => {\n clearCurrentPurchase();\n clearCurrentPurchaseError();\n\n try {\n return await requestPurchaseInternal(requestObj);\n } catch (error) {\n throw error;\n }\n },\n [clearCurrentPurchase, clearCurrentPurchaseError],\n );\n\n const refreshSubscriptionStatus = useCallback(\n async (productId: string) => {\n try {\n if (subscriptionsRefState.current.some((sub) => sub.id === productId)) {\n await getSubscriptionsInternal([productId]);\n await getAvailablePurchasesInternal();\n }\n } catch (error) {\n console.warn('Failed to refresh subscription status:', error);\n }\n },\n [getAvailablePurchasesInternal, getSubscriptionsInternal],\n );\n\n const restorePurchases = useCallback(async (): Promise<void> => {\n try {\n if (Platform.OS === 'ios') {\n await syncIOS().catch((error) => {\n if (optionsRef.current?.onSyncError) {\n optionsRef.current.onSyncError(error);\n } else {\n console.warn('Error restoring purchases:', error);\n }\n });\n }\n await getAvailablePurchasesInternal();\n } catch (error) {\n console.warn('Failed to restore purchases:', error);\n }\n }, [getAvailablePurchasesInternal]);\n\n const validateReceipt = useCallback(\n async (\n sku: string,\n androidOptions?: {\n packageName: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n },\n ) => {\n return validateReceiptInternal(sku, androidOptions);\n },\n [],\n );\n\n const initIapWithSubscriptions = useCallback(async (): Promise<void> => {\n const result = await initConnection();\n setConnected(result);\n\n if (result) {\n subscriptionsRef.current.purchaseUpdate = purchaseUpdatedListener(\n async (purchase: Purchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n\n if ('expirationDateIOS' in purchase) {\n await refreshSubscriptionStatus(purchase.id);\n }\n\n if (optionsRef.current?.onPurchaseSuccess) {\n optionsRef.current.onPurchaseSuccess(purchase);\n }\n },\n );\n\n subscriptionsRef.current.purchaseError = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n\n if (optionsRef.current?.onPurchaseError) {\n optionsRef.current.onPurchaseError(error);\n }\n },\n );\n\n if (Platform.OS === 'ios') {\n // iOS promoted products listener\n subscriptionsRef.current.promotedProductsIOS =\n promotedProductListenerIOS((product: Product) => {\n setPromotedProductIOS(product);\n\n if (optionsRef.current?.onPromotedProductIOS) {\n optionsRef.current.onPromotedProductIOS(product);\n }\n });\n }\n }\n }, [refreshSubscriptionStatus]);\n\n useEffect(() => {\n initIapWithSubscriptions();\n const currentSubscriptions = subscriptionsRef.current;\n\n return () => {\n currentSubscriptions.purchaseUpdate?.remove();\n currentSubscriptions.purchaseError?.remove();\n currentSubscriptions.promotedProductsIOS?.remove();\n currentSubscriptions.promotedProductIOS?.remove();\n endConnection();\n setConnected(false);\n };\n }, [initIapWithSubscriptions]);\n\n return {\n connected,\n products,\n promotedProductsIOS,\n promotedProductIdIOS,\n subscriptions,\n purchaseHistories,\n finishTransaction,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n promotedProductIOS,\n activeSubscriptions,\n clearCurrentPurchase,\n clearCurrentPurchaseError,\n getAvailablePurchases: getAvailablePurchasesInternal,\n getPurchaseHistories: getPurchaseHistoriesInternal,\n fetchProducts: fetchProductsInternal,\n requestProducts: requestProductsInternal,\n requestPurchase: requestPurchaseWithReset,\n validateReceipt,\n restorePurchases,\n getProducts: getProductsInternal,\n getSubscriptions: getSubscriptionsInternal,\n getPromotedProductIOS,\n requestPurchaseOnPromotedProductIOS,\n buyPromotedProductIOS: requestPurchaseOnPromotedProductIOS, // deprecated alias\n getActiveSubscriptions: getActiveSubscriptionsInternal,\n hasActiveSubscriptions: hasActiveSubscriptionsInternal,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,EAAE,MAAM,EAG/B,CAAC;AAGF,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAA+B,CAAC;AAG7E,eAAO,MAAM,+BAA+B,QAA8B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Centralized product ID constants for examples and internal usage
|
|
2
|
+
// Rename guide: subscriptionIds -> SUBSCRIPTION_PRODUCT_IDS, PRODUCT_IDS remains the same name
|
|
3
|
+
// One-time purchase product IDs (consumables/non-consumables)
|
|
4
|
+
export const PRODUCT_IDS = [
|
|
5
|
+
'dev.hyo.martie.10bulbs',
|
|
6
|
+
'dev.hyo.martie.30bulbs',
|
|
7
|
+
];
|
|
8
|
+
// Subscription product IDs
|
|
9
|
+
export const SUBSCRIPTION_PRODUCT_IDS = ['dev.hyo.martie.premium'];
|
|
10
|
+
// Optionally export a single default subscription for convenience
|
|
11
|
+
export const DEFAULT_SUBSCRIPTION_PRODUCT_ID = SUBSCRIPTION_PRODUCT_IDS[0];
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,+FAA+F;AAE/F,8DAA8D;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAa;IACnC,wBAAwB;IACxB,wBAAwB;CACzB,CAAC;AAEF,2BAA2B;AAC3B,MAAM,CAAC,MAAM,wBAAwB,GAAa,CAAC,wBAAwB,CAAC,CAAC;AAE7E,kEAAkE;AAClE,MAAM,CAAC,MAAM,+BAA+B,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC","sourcesContent":["// Centralized product ID constants for examples and internal usage\n// Rename guide: subscriptionIds -> SUBSCRIPTION_PRODUCT_IDS, PRODUCT_IDS remains the same name\n\n// One-time purchase product IDs (consumables/non-consumables)\nexport const PRODUCT_IDS: string[] = [\n 'dev.hyo.martie.10bulbs',\n 'dev.hyo.martie.30bulbs',\n];\n\n// Subscription product IDs\nexport const SUBSCRIPTION_PRODUCT_IDS: string[] = ['dev.hyo.martie.premium'];\n\n// Optionally export a single default subscription for convenience\nexport const DEFAULT_SUBSCRIPTION_PRODUCT_ID = SUBSCRIPTION_PRODUCT_IDS[0];\n"]}
|
package/ios/ExpoIapModule.swift
CHANGED
|
@@ -114,7 +114,6 @@ func serializeTransaction(_ transaction: Transaction, jwsRepresentationIOS: Stri
|
|
|
114
114
|
if let currency = jsonData["currency"] as? String {
|
|
115
115
|
purchaseMap["currencyCodeIOS"] = currency
|
|
116
116
|
|
|
117
|
-
// Try to get currency symbol from locale
|
|
118
117
|
let locale = Locale(identifier: Locale.identifier(fromComponents: [NSLocale.Key.currencyCode.rawValue: currency]))
|
|
119
118
|
purchaseMap["currencySymbolIOS"] = locale.currencySymbol
|
|
120
119
|
|
|
@@ -123,7 +122,6 @@ func serializeTransaction(_ transaction: Transaction, jwsRepresentationIOS: Stri
|
|
|
123
122
|
purchaseMap["currencyIOS"] = currency
|
|
124
123
|
// END: Deprecated - will be removed in v2.9.0
|
|
125
124
|
}
|
|
126
|
-
// Extract country code from storefront if available
|
|
127
125
|
if let storefront = jsonData["storefront"] as? String {
|
|
128
126
|
purchaseMap["countryCodeIOS"] = storefront
|
|
129
127
|
}
|
|
@@ -178,10 +176,8 @@ func serializeSubscription(_ s: Product.SubscriptionInfo?) -> [String: Any?]? {
|
|
|
178
176
|
|
|
179
177
|
@available(iOS 15.0, *)
|
|
180
178
|
func serializeProduct(_ p: Product) -> [String: Any?] {
|
|
181
|
-
// Convert Product.ProductType to our expected 'inapp' or 'subs' string
|
|
182
179
|
let productType: String = p.subscription != nil ? "subs" : "inapp"
|
|
183
180
|
|
|
184
|
-
// For subscription products, add discounts and introductory price
|
|
185
181
|
var discounts: [[String: Any?]]? = nil
|
|
186
182
|
var introductoryPrice: String? = nil
|
|
187
183
|
var introductoryPriceAsAmountIOS: String? = nil
|
|
@@ -192,7 +188,6 @@ func serializeProduct(_ p: Product) -> [String: Any?] {
|
|
|
192
188
|
var subscriptionPeriodUnitIOS: String? = nil
|
|
193
189
|
|
|
194
190
|
if let subscription = p.subscription {
|
|
195
|
-
// Extract discount information from promotional offers
|
|
196
191
|
if !subscription.promotionalOffers.isEmpty {
|
|
197
192
|
discounts = subscription.promotionalOffers.compactMap { offer in
|
|
198
193
|
return [
|
|
@@ -207,7 +202,6 @@ func serializeProduct(_ p: Product) -> [String: Any?] {
|
|
|
207
202
|
}
|
|
208
203
|
}
|
|
209
204
|
|
|
210
|
-
// Extract introductory price from introductory offer
|
|
211
205
|
if let introOffer = subscription.introductoryOffer {
|
|
212
206
|
introductoryPrice = introOffer.displayPrice
|
|
213
207
|
introductoryPriceAsAmountIOS = "\(introOffer.price)"
|
|
@@ -216,7 +210,6 @@ func serializeProduct(_ p: Product) -> [String: Any?] {
|
|
|
216
210
|
introductoryPriceSubscriptionPeriodIOS = getPeriodIOS(introOffer.period.unit)
|
|
217
211
|
}
|
|
218
212
|
|
|
219
|
-
// Extract subscription period information
|
|
220
213
|
subscriptionPeriodNumberIOS = "\(subscription.subscriptionPeriod.value)"
|
|
221
214
|
subscriptionPeriodUnitIOS = getPeriodIOS(subscription.subscriptionPeriod.unit)
|
|
222
215
|
}
|
|
@@ -224,7 +217,6 @@ func serializeProduct(_ p: Product) -> [String: Any?] {
|
|
|
224
217
|
return [
|
|
225
218
|
"debugDescription": serializeDebug(p.debugDescription),
|
|
226
219
|
"description": p.description,
|
|
227
|
-
// New iOS-suffixed fields
|
|
228
220
|
"displayNameIOS": p.displayName,
|
|
229
221
|
"discountsIOS": discounts,
|
|
230
222
|
"introductoryPriceIOS": introductoryPrice,
|
|
@@ -308,13 +300,11 @@ public class ExpoIapModule: Module {
|
|
|
308
300
|
private var productStore: ProductStore?
|
|
309
301
|
private var hasListeners = false
|
|
310
302
|
private var updateListenerTask: Task<Void, Error>?
|
|
311
|
-
private var subscriptionPollingTask: Task<Void, Error>?
|
|
312
|
-
private var pollingSkus: Set<String> = []
|
|
313
303
|
private var paymentObserver: PaymentObserver?
|
|
314
304
|
private var promotedPayment: SKPayment?
|
|
315
305
|
private var promotedProduct: SKProduct?
|
|
316
306
|
|
|
317
|
-
|
|
307
|
+
private let subscriptionChangePropagationDelay: UInt64 = 1_500_000_000 // 1.5 seconds in nanoseconds
|
|
318
308
|
private var isInitialized = false
|
|
319
309
|
|
|
320
310
|
public func definition() -> ModuleDefinition {
|
|
@@ -337,13 +327,10 @@ public class ExpoIapModule: Module {
|
|
|
337
327
|
}
|
|
338
328
|
|
|
339
329
|
Function("initConnection") { () -> Bool in
|
|
340
|
-
// Clean up any existing state first (important for hot reload)
|
|
341
330
|
self.cleanupExistingState()
|
|
342
331
|
|
|
343
|
-
// Initialize fresh state
|
|
344
332
|
self.productStore = ProductStore()
|
|
345
333
|
|
|
346
|
-
// Set up PaymentObserver for promoted products
|
|
347
334
|
if self.paymentObserver == nil {
|
|
348
335
|
self.paymentObserver = PaymentObserver(module: self)
|
|
349
336
|
SKPaymentQueue.default().add(self.paymentObserver!)
|
|
@@ -416,7 +403,6 @@ public class ExpoIapModule: Module {
|
|
|
416
403
|
return nil
|
|
417
404
|
}
|
|
418
405
|
|
|
419
|
-
// Convert SKProduct to dictionary
|
|
420
406
|
return [
|
|
421
407
|
"productIdentifier": product.productIdentifier,
|
|
422
408
|
"localizedTitle": product.localizedTitle,
|
|
@@ -439,10 +425,8 @@ public class ExpoIapModule: Module {
|
|
|
439
425
|
)
|
|
440
426
|
}
|
|
441
427
|
|
|
442
|
-
// Add the deferred payment to the queue
|
|
443
428
|
SKPaymentQueue.default().add(payment)
|
|
444
429
|
|
|
445
|
-
// Clear the promoted product data
|
|
446
430
|
self.promotedPayment = nil
|
|
447
431
|
self.promotedProduct = nil
|
|
448
432
|
}
|
|
@@ -504,63 +488,26 @@ public class ExpoIapModule: Module {
|
|
|
504
488
|
func addTransaction(transaction: Transaction, jwsRepresentationIOS: String? = nil) {
|
|
505
489
|
let serialized = serializeTransaction(transaction, jwsRepresentationIOS: jwsRepresentationIOS)
|
|
506
490
|
purchasedItemsSerialized.append(serialized)
|
|
507
|
-
|
|
508
|
-
if alsoPublishToEventListenerIOS {
|
|
509
|
-
self.sendEvent(IapEvent.PurchaseUpdated, serialized)
|
|
510
|
-
}
|
|
511
491
|
}
|
|
512
492
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if !onlyIncludeActiveItemsIOS {
|
|
519
|
-
addTransaction(transaction: transaction, jwsRepresentationIOS: verification.jwsRepresentation)
|
|
520
|
-
continue
|
|
521
|
-
}
|
|
522
|
-
switch transaction.productType {
|
|
523
|
-
case .nonConsumable, .autoRenewable, .consumable:
|
|
524
|
-
if await self.productStore?.getProduct(productID: transaction.productID)
|
|
525
|
-
!= nil
|
|
526
|
-
{
|
|
493
|
+
if onlyIncludeActiveItemsIOS {
|
|
494
|
+
for await verification in Transaction.currentEntitlements {
|
|
495
|
+
do {
|
|
496
|
+
let transaction = try self.checkVerified(verification)
|
|
497
|
+
if await self.productStore?.getProduct(productID: transaction.productID) != nil {
|
|
527
498
|
addTransaction(transaction: transaction, jwsRepresentationIOS: verification.jwsRepresentation)
|
|
528
499
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
!= nil
|
|
532
|
-
{
|
|
533
|
-
let currentDate = Date()
|
|
534
|
-
let expirationDate = Calendar(identifier: .gregorian).date(
|
|
535
|
-
byAdding: DateComponents(year: 1), to: transaction.purchaseDate)!
|
|
536
|
-
if currentDate < expirationDate {
|
|
537
|
-
addTransaction(transaction: transaction, jwsRepresentationIOS: verification.jwsRepresentation)
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
default:
|
|
541
|
-
break
|
|
542
|
-
}
|
|
543
|
-
} catch StoreError.failedVerification {
|
|
544
|
-
let err = [
|
|
545
|
-
"responseCode": IapErrorCode.transactionValidationFailed,
|
|
546
|
-
"debugMessage": StoreError.failedVerification.localizedDescription,
|
|
547
|
-
"code": IapErrorCode.transactionValidationFailed,
|
|
548
|
-
"message": StoreError.failedVerification.localizedDescription,
|
|
549
|
-
"productId": "unknown",
|
|
550
|
-
]
|
|
551
|
-
if alsoPublishToEventListenerIOS {
|
|
552
|
-
self.sendEvent(IapEvent.PurchaseError, err)
|
|
500
|
+
} catch {
|
|
501
|
+
print("[ExpoIapModule] Failed to verify transaction: \(error)")
|
|
553
502
|
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if alsoPublishToEventListenerIOS {
|
|
563
|
-
self.sendEvent(IapEvent.PurchaseError, err)
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
for await verification in Transaction.all {
|
|
506
|
+
do {
|
|
507
|
+
let transaction = try self.checkVerified(verification)
|
|
508
|
+
addTransaction(transaction: transaction, jwsRepresentationIOS: verification.jwsRepresentation)
|
|
509
|
+
} catch {
|
|
510
|
+
print("[ExpoIapModule] Failed to verify transaction: \(error)")
|
|
564
511
|
}
|
|
565
512
|
}
|
|
566
513
|
}
|
|
@@ -631,7 +578,6 @@ public class ExpoIapModule: Module {
|
|
|
631
578
|
case .success(let verification):
|
|
632
579
|
let transaction = try self.checkVerified(verification)
|
|
633
580
|
|
|
634
|
-
// Debug: Log JWS representation
|
|
635
581
|
let jwsRepresentation = verification.jwsRepresentation
|
|
636
582
|
if !jwsRepresentation.isEmpty {
|
|
637
583
|
logDebug("buyProduct JWS: exists")
|
|
@@ -647,7 +593,6 @@ public class ExpoIapModule: Module {
|
|
|
647
593
|
self.transactions[String(transaction.id)] = transaction
|
|
648
594
|
let serialized = serializeTransaction(transaction, jwsRepresentationIOS: verification.jwsRepresentation)
|
|
649
595
|
|
|
650
|
-
// Debug: Check if jwsRepresentationIOS is included in serialized result
|
|
651
596
|
logDebug("buyProduct serialized includes JWS: \(serialized["jwsRepresentationIOS"] != nil)")
|
|
652
597
|
|
|
653
598
|
self.sendEvent(IapEvent.PurchaseUpdated, serialized)
|
|
@@ -689,15 +634,12 @@ public class ExpoIapModule: Module {
|
|
|
689
634
|
throw error
|
|
690
635
|
}
|
|
691
636
|
|
|
692
|
-
// Map StoreKit errors to proper error codes
|
|
693
637
|
var errorCode = IapErrorCode.purchaseError
|
|
694
638
|
var errorMessage = error.localizedDescription
|
|
695
639
|
|
|
696
|
-
// Check for specific StoreKit error types
|
|
697
640
|
if let nsError = error as NSError? {
|
|
698
641
|
switch nsError.domain {
|
|
699
642
|
case "SKErrorDomain":
|
|
700
|
-
// Handle SKError codes
|
|
701
643
|
switch nsError.code {
|
|
702
644
|
case 0: // SKError.unknown
|
|
703
645
|
errorCode = IapErrorCode.unknown
|
|
@@ -866,19 +808,76 @@ public class ExpoIapModule: Module {
|
|
|
866
808
|
#endif
|
|
867
809
|
}
|
|
868
810
|
|
|
869
|
-
AsyncFunction("showManageSubscriptionsIOS") { () ->
|
|
811
|
+
AsyncFunction("showManageSubscriptionsIOS") { () -> [[String: Any?]] in
|
|
870
812
|
#if !os(tvOS)
|
|
871
813
|
guard let windowScene = await self.currentWindowScene() else {
|
|
872
814
|
throw Exception(name: "ExpoIapModule", description: "Cannot find window scene or not available on macOS", code: IapErrorCode.serviceError)
|
|
873
815
|
}
|
|
874
|
-
|
|
816
|
+
|
|
817
|
+
var beforeStatuses: [String: Bool] = [:]
|
|
875
818
|
let subscriptionSkus = await self.getAllSubscriptionProductIds()
|
|
876
|
-
|
|
877
|
-
|
|
819
|
+
|
|
820
|
+
for sku in subscriptionSkus {
|
|
821
|
+
if let product = await self.productStore?.getProduct(productID: sku),
|
|
822
|
+
let subscription = product.subscription {
|
|
823
|
+
do {
|
|
824
|
+
let statuses = try await subscription.status
|
|
825
|
+
if let s = statuses.first(where: { status in
|
|
826
|
+
if case .verified(let info) = status.renewalInfo {
|
|
827
|
+
return info.currentProductID == sku
|
|
828
|
+
}
|
|
829
|
+
return false
|
|
830
|
+
}) {
|
|
831
|
+
var willAutoRenew = false
|
|
832
|
+
if case .verified(let info) = s.renewalInfo {
|
|
833
|
+
willAutoRenew = info.willAutoRenew
|
|
834
|
+
}
|
|
835
|
+
beforeStatuses[sku] = willAutoRenew
|
|
836
|
+
}
|
|
837
|
+
} catch {
|
|
838
|
+
// ignore
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
878
843
|
try await AppStore.showManageSubscriptions(in: windowScene)
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
844
|
+
|
|
845
|
+
try? await Task.sleep(nanoseconds: subscriptionChangePropagationDelay)
|
|
846
|
+
|
|
847
|
+
var updatedSubscriptions: [[String: Any?]] = []
|
|
848
|
+
|
|
849
|
+
for sku in subscriptionSkus {
|
|
850
|
+
if let product = await self.productStore?.getProduct(productID: sku),
|
|
851
|
+
let subscription = product.subscription,
|
|
852
|
+
let result = await product.latestTransaction {
|
|
853
|
+
let statuses = try? await subscription.status
|
|
854
|
+
let matchedStatus = statuses?.first(where: { status in
|
|
855
|
+
if case .verified(let info) = status.renewalInfo {
|
|
856
|
+
return info.currentProductID == sku
|
|
857
|
+
}
|
|
858
|
+
return false
|
|
859
|
+
})
|
|
860
|
+
|
|
861
|
+
var currentWillAutoRenew = false
|
|
862
|
+
if let s = matchedStatus, case .verified(let info) = s.renewalInfo {
|
|
863
|
+
currentWillAutoRenew = info.willAutoRenew
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
let previousWillAutoRenew = beforeStatuses[sku] ?? false
|
|
867
|
+
if previousWillAutoRenew != currentWillAutoRenew {
|
|
868
|
+
do {
|
|
869
|
+
let transaction = try self.checkVerified(result)
|
|
870
|
+
var purchaseMap = serializeTransaction(transaction, jwsRepresentationIOS: result.jwsRepresentation)
|
|
871
|
+
purchaseMap["willAutoRenewIOS"] = currentWillAutoRenew
|
|
872
|
+
updatedSubscriptions.append(purchaseMap)
|
|
873
|
+
} catch {
|
|
874
|
+
print("[ExpoIapModule] Failed to verify subscription change: \(error)")
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
return updatedSubscriptions
|
|
882
881
|
#else
|
|
883
882
|
throw Exception(name: "ExpoIapModule", description: "This method is not available on tvOS", code: IapErrorCode.serviceError)
|
|
884
883
|
#endif
|
|
@@ -1037,12 +1036,8 @@ public class ExpoIapModule: Module {
|
|
|
1037
1036
|
updateListenerTask?.cancel()
|
|
1038
1037
|
updateListenerTask = nil
|
|
1039
1038
|
|
|
1040
|
-
subscriptionPollingTask?.cancel()
|
|
1041
|
-
subscriptionPollingTask = nil
|
|
1042
|
-
|
|
1043
1039
|
// Clear collections
|
|
1044
1040
|
transactions.removeAll()
|
|
1045
|
-
pollingSkus.removeAll()
|
|
1046
1041
|
|
|
1047
1042
|
// Reset promoted products
|
|
1048
1043
|
promotedPayment = nil
|
|
@@ -1138,71 +1133,6 @@ public class ExpoIapModule: Module {
|
|
|
1138
1133
|
}
|
|
1139
1134
|
}
|
|
1140
1135
|
|
|
1141
|
-
private func pollForSubscriptionStatusChanges() {
|
|
1142
|
-
subscriptionPollingTask?.cancel()
|
|
1143
|
-
subscriptionPollingTask = Task {
|
|
1144
|
-
try? await Task.sleep(nanoseconds: 1_500_000_000) // 1.5 seconds
|
|
1145
|
-
|
|
1146
|
-
var previousStatuses: [String: Bool] = [:] // Track auto-renewal state with Bool
|
|
1147
|
-
|
|
1148
|
-
for sku in self.pollingSkus {
|
|
1149
|
-
guard let product = await self.productStore?.getProduct(productID: sku),
|
|
1150
|
-
let status = try? await product.subscription?.status.first else { continue }
|
|
1151
|
-
|
|
1152
|
-
// Track willAutoRenew as a bool value
|
|
1153
|
-
var willAutoRenew = false
|
|
1154
|
-
if case .verified(let info) = status.renewalInfo {
|
|
1155
|
-
willAutoRenew = info.willAutoRenew
|
|
1156
|
-
}
|
|
1157
|
-
previousStatuses[sku] = willAutoRenew
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
for _ in 1...5 {
|
|
1161
|
-
try? await Task.sleep(nanoseconds: 2_000_000_000) // 2 seconds
|
|
1162
|
-
if Task.isCancelled {
|
|
1163
|
-
return
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
for sku in self.pollingSkus {
|
|
1167
|
-
guard let product = await self.productStore?.getProduct(productID: sku),
|
|
1168
|
-
let status = try? await product.subscription?.status.first,
|
|
1169
|
-
let result = await product.latestTransaction else { continue }
|
|
1170
|
-
// Try to verify the transaction
|
|
1171
|
-
let transaction: Transaction
|
|
1172
|
-
do {
|
|
1173
|
-
transaction = try self.checkVerified(result)
|
|
1174
|
-
} catch {
|
|
1175
|
-
continue // Skip if verification fails
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
// Track current auto-renewal state
|
|
1179
|
-
var currentWillAutoRenew = false
|
|
1180
|
-
if case .verified(let info) = status.renewalInfo {
|
|
1181
|
-
currentWillAutoRenew = info.willAutoRenew
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
// Compare with previous state
|
|
1185
|
-
if let previousWillAutoRenew = previousStatuses[sku],
|
|
1186
|
-
previousWillAutoRenew != currentWillAutoRenew {
|
|
1187
|
-
|
|
1188
|
-
// Use the jwsRepresentation when serializing the transaction
|
|
1189
|
-
var purchaseMap = serializeTransaction(transaction, jwsRepresentationIOS: result.jwsRepresentation)
|
|
1190
|
-
|
|
1191
|
-
if case .verified(let renewalInfo) = status.renewalInfo {
|
|
1192
|
-
if let renewalInfoDict = serializeRenewalInfo(.verified(renewalInfo)) {
|
|
1193
|
-
purchaseMap["renewalInfo"] = renewalInfoDict
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
self.sendEvent(IapEvent.PurchaseUpdated, purchaseMap)
|
|
1198
|
-
previousStatuses[sku] = currentWillAutoRenew
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
self.pollingSkus.removeAll()
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
1136
|
private func getReceiptDataInternal() throws -> String {
|
|
1207
1137
|
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
|
|
1208
1138
|
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-iap",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "In App Purchase module in Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"docs:start": "cd docs && bun run start",
|
|
26
26
|
"docs:build": "cd docs && bun run build",
|
|
27
27
|
"docs:serve": "cd docs && bun run serve",
|
|
28
|
-
"docs:install": "cd docs && bun install"
|
|
28
|
+
"docs:install": "cd docs && bun install",
|
|
29
|
+
"generate:icon": "npx sharp-cli resize 32 32 -i docs/static/img/icon.png -o docs/static/img/favicon-32x32.png && npx sharp-cli resize 16 16 -i docs/static/img/icon.png -o docs/static/img/favicon-16x16.png && npx sharp-cli resize 180 180 -i docs/static/img/icon.png -o docs/static/img/apple-touch-icon.png && npx sharp-cli resize 192 192 -i docs/static/img/icon.png -o docs/static/img/android-chrome-192x192.png && npx sharp-cli resize 512 512 -i docs/static/img/icon.png -o docs/static/img/android-chrome-512x512.png && npx sharp-cli resize 150 150 -i docs/static/img/icon.png -o docs/static/img/mstile-150x150.png && npx sharp-cli resize 1200 630 -i docs/static/img/icon.png -o docs/static/img/og-image.png && npx sharp-cli resize 1200 600 -i docs/static/img/icon.png -o docs/static/img/twitter-card.png && npx sharp-cli resize 16 16 -i docs/static/img/icon.png -o docs/static/img/favicon.png && cp docs/static/img/favicon-16x16.png docs/static/img/favicon.ico"
|
|
29
30
|
},
|
|
30
31
|
"keywords": [
|
|
31
32
|
"react-native",
|
|
@@ -4,6 +4,9 @@ import {getAvailablePurchases} from '../index';
|
|
|
4
4
|
export interface ActiveSubscription {
|
|
5
5
|
productId: string;
|
|
6
6
|
isActive: boolean;
|
|
7
|
+
transactionId: string; // Transaction identifier for backend validation
|
|
8
|
+
purchaseToken?: string; // JWT token (iOS) or purchase token (Android) for backend validation
|
|
9
|
+
transactionDate: number; // Transaction timestamp
|
|
7
10
|
expirationDateIOS?: Date;
|
|
8
11
|
autoRenewingAndroid?: boolean;
|
|
9
12
|
environmentIOS?: string;
|
|
@@ -79,6 +82,9 @@ export const getActiveSubscriptions = async (
|
|
|
79
82
|
const subscription: ActiveSubscription = {
|
|
80
83
|
productId: purchase.productId,
|
|
81
84
|
isActive: true,
|
|
85
|
+
transactionId: purchase.transactionId || purchase.id,
|
|
86
|
+
purchaseToken: purchase.purchaseToken,
|
|
87
|
+
transactionDate: purchase.transactionDate,
|
|
82
88
|
};
|
|
83
89
|
|
|
84
90
|
// Add platform-specific details
|
package/src/modules/ios.ts
CHANGED
|
@@ -168,15 +168,14 @@ export const beginRefundRequestIOS = (
|
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* Shows the system UI for managing subscriptions.
|
|
171
|
-
*
|
|
172
|
-
* purchaseUpdatedListener and transactionUpdatedIOS listeners.
|
|
171
|
+
* Returns an array of subscriptions that had status changes after the UI is closed.
|
|
173
172
|
*
|
|
174
|
-
* @returns Promise
|
|
173
|
+
* @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)
|
|
175
174
|
* @throws Error if called on non-iOS platform
|
|
176
175
|
*
|
|
177
176
|
* @platform iOS
|
|
178
177
|
*/
|
|
179
|
-
export const showManageSubscriptionsIOS = (): Promise<
|
|
178
|
+
export const showManageSubscriptionsIOS = (): Promise<Purchase[]> => {
|
|
180
179
|
return ExpoIapModule.showManageSubscriptionsIOS();
|
|
181
180
|
};
|
|
182
181
|
|
|
@@ -415,7 +414,7 @@ export const beginRefundRequest = (
|
|
|
415
414
|
/**
|
|
416
415
|
* @deprecated Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.
|
|
417
416
|
*/
|
|
418
|
-
export const showManageSubscriptions = (): Promise<
|
|
417
|
+
export const showManageSubscriptions = (): Promise<Purchase[]> => {
|
|
419
418
|
console.warn(
|
|
420
419
|
'`showManageSubscriptions` is deprecated. Use `showManageSubscriptionsIOS` instead. This function will be removed in version 3.0.0.',
|
|
421
420
|
);
|
package/src/useIAP.ts
CHANGED
|
@@ -264,7 +264,10 @@ export function useIAP(options?: UseIAPOptions): UseIap {
|
|
|
264
264
|
|
|
265
265
|
const getAvailablePurchasesInternal = useCallback(async (): Promise<void> => {
|
|
266
266
|
try {
|
|
267
|
-
const result = await getAvailablePurchases(
|
|
267
|
+
const result = await getAvailablePurchases({
|
|
268
|
+
alsoPublishToEventListenerIOS: false,
|
|
269
|
+
onlyIncludeActiveItemsIOS: true,
|
|
270
|
+
});
|
|
268
271
|
setAvailablePurchases(result);
|
|
269
272
|
} catch (error) {
|
|
270
273
|
console.error('Error fetching available purchases:', error);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Centralized product ID constants for examples and internal usage
|
|
2
|
+
// Rename guide: subscriptionIds -> SUBSCRIPTION_PRODUCT_IDS, PRODUCT_IDS remains the same name
|
|
3
|
+
|
|
4
|
+
// One-time purchase product IDs (consumables/non-consumables)
|
|
5
|
+
export const PRODUCT_IDS: string[] = [
|
|
6
|
+
'dev.hyo.martie.10bulbs',
|
|
7
|
+
'dev.hyo.martie.30bulbs',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
// Subscription product IDs
|
|
11
|
+
export const SUBSCRIPTION_PRODUCT_IDS: string[] = ['dev.hyo.martie.premium'];
|
|
12
|
+
|
|
13
|
+
// Optionally export a single default subscription for convenience
|
|
14
|
+
export const DEFAULT_SUBSCRIPTION_PRODUCT_ID = SUBSCRIPTION_PRODUCT_IDS[0];
|