expo-iap 2.5.2 → 2.5.3-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,4 +40,12 @@ export declare const acknowledgePurchaseAndroid: ({ token, developerPayload, }:
40
40
  token: string;
41
41
  developerPayload?: string;
42
42
  }) => Promise<PurchaseResult | boolean | void>;
43
+ /**
44
+ * Open the Google Play Store to redeem offer codes (Android only).
45
+ * Note: Google Play does not provide a direct API to redeem codes within the app.
46
+ * This function opens the Play Store where users can manually enter their codes.
47
+ *
48
+ * @returns {Promise<void>}
49
+ */
50
+ export declare const openRedeemOfferCodeAndroid: () => Promise<void>;
43
51
  //# sourceMappingURL=android.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAI7D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,EAC5D,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,CAAC,GAAG;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAC,CAOnC;AAED;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,GAAU,UAElD;IACD,GAAG,EAAE,MAAM,CAAC;CACb,KAAG,OAAO,CAAC,IAAI,CAIf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAU,+DAM1C;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,KAAG,OAAO,CAAC,cAAc,CAuBzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,8BAGxC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,KAAG,OAAO,CAAC,cAAc,GAAG,OAAO,GAAG,IAAI,CAE1C,CAAC"}
1
+ {"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAI7D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,EAC5D,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,CAAC,GAAG;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAC,CAOnC;AAED;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,GAAU,UAElD;IACD,GAAG,EAAE,MAAM,CAAC;CACb,KAAG,OAAO,CAAC,IAAI,CAIf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAU,+DAM1C;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,KAAG,OAAO,CAAC,cAAc,CAuBzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,8BAGxC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,KAAG,OAAO,CAAC,cAAc,GAAG,OAAO,GAAG,IAAI,CAE1C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,QAAa,OAAO,CAAC,IAAI,CAI/D,CAAC"}
@@ -53,4 +53,14 @@ export const validateReceiptAndroid = async ({ packageName, productId, productTo
53
53
  export const acknowledgePurchaseAndroid = ({ token, developerPayload, }) => {
54
54
  return ExpoIapModule.acknowledgePurchase(token, developerPayload);
55
55
  };
56
+ /**
57
+ * Open the Google Play Store to redeem offer codes (Android only).
58
+ * Note: Google Play does not provide a direct API to redeem codes within the app.
59
+ * This function opens the Play Store where users can manually enter their codes.
60
+ *
61
+ * @returns {Promise<void>}
62
+ */
63
+ export const openRedeemOfferCodeAndroid = async () => {
64
+ return Linking.openURL(`https://play.google.com/redeem?code=`);
65
+ };
56
66
  //# sourceMappingURL=android.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAGrC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,cAAc;AACd,MAAM,UAAU,gBAAgB,CAC9B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,IAAI,CAAC,QAAQ,KAAK,SAAS,CAC5B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,EAAE,EACnD,GAAG,GAGJ,EAAiB,EAAE;IAClB,OAAO,OAAO,CAAC,OAAO,CACpB,+DAA+D,MAAM,aAAa,CAAC,cAAc,EAAE,QAAQ,GAAG,EAAE,CACjH,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,EAC3C,WAAW,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,KAAK,GAON,EAA2B,EAAE;IAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC;IAElD,MAAM,GAAG,GACP,0EAA0E;QAC1E,IAAI,WAAW,cAAc,IAAI,IAAI,SAAS,EAAE;QAChD,WAAW,YAAY,EAAE,CAAC;IAE5B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAClD,UAAU,EAAE,QAAQ,CAAC,MAAM;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EACzC,KAAK,EACL,gBAAgB,GAIjB,EAA4C,EAAE;IAC7C,OAAO,aAAa,CAAC,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import {Linking} from 'react-native';\nimport {PurchaseResult} from '../ExpoIap.types';\nimport {ReceiptAndroid} from '../types/ExpoIapAndroid.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Type guards\nexport function isProductAndroid<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'android'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'android'\n );\n}\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async ({\n sku,\n}: {\n sku: string;\n}): Promise<void> => {\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await ExpoIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase (called 'token' in the API documentation).\n * @param {string} accessToken OAuth access token with androidpublisher scope. Required for authentication.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<ReceiptAndroid>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<ReceiptAndroid> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = ({\n token,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | void> => {\n return ExpoIapModule.acknowledgePurchase(token, developerPayload);\n};\n"]}
1
+ {"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAGrC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,cAAc;AACd,MAAM,UAAU,gBAAgB,CAC9B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,IAAI,CAAC,QAAQ,KAAK,SAAS,CAC5B,CAAC;AACJ,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MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,IAAmB,EAAE;IAClE,OAAO,OAAO,CAAC,OAAO,CACpB,sCAAsC,CACvC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Linking} from 'react-native';\nimport {PurchaseResult} from '../ExpoIap.types';\nimport {ReceiptAndroid} from '../types/ExpoIapAndroid.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Type guards\nexport function isProductAndroid<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'android'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'android'\n );\n}\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async ({\n sku,\n}: {\n sku: string;\n}): Promise<void> => {\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await ExpoIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase (called 'token' in the API documentation).\n * @param {string} accessToken OAuth access token with androidpublisher scope. Required for authentication.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<ReceiptAndroid>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<ReceiptAndroid> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = ({\n token,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | void> => {\n return ExpoIapModule.acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Open the Google Play Store to redeem offer codes (Android only).\n * Note: Google Play does not provide a direct API to redeem codes within the app.\n * This function opens the Play Store where users can manually enter their codes.\n * \n * @returns {Promise<void>}\n */\nexport const openRedeemOfferCodeAndroid = async (): Promise<void> => {\n return Linking.openURL(\n `https://play.google.com/redeem?code=`\n );\n};\n"]}
@@ -106,5 +106,15 @@ export declare const validateReceiptIos: (sku: string) => Promise<{
106
106
  jwsRepresentation: string;
107
107
  latestTransaction?: ProductPurchase;
108
108
  }>;
109
+ /**
110
+ * Present the code redemption sheet for offer codes (iOS only).
111
+ * This allows users to redeem promotional codes for in-app purchases and subscriptions.
112
+ *
113
+ * Note: This only works on real devices, not simulators.
114
+ *
115
+ * @returns {Promise<boolean>} True if the sheet was presented successfully
116
+ * @throws {Error} If called on non-iOS platform or tvOS
117
+ */
118
+ export declare const presentCodeRedemptionSheet: () => Promise<boolean>;
109
119
  export {};
110
120
  //# sourceMappingURL=ios.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,aAAa,EAGd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAGhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,KAAK,CAAC,EAAE,aAAa,CAAC;CAC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eAAe,CACjC,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,eAAe,CACjC,CAAC;AAEvC;;GAEG;AACH,KAAK,mBAAmB,GAAG,SAAS,GAAG,eAAe,CAAC;AACvD,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,mBAAmB,CACrC,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAO,OAAO,CAAC,IAAI,CACd,CAAC;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,QAAO,OAAO,CAAC,MAAM,CAK9C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAKlE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CAK7D,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,GAC7B,KAAK,MAAM,KACV,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,eAAe,CAAC;CACrC,CAOA,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,QAAO,OAAO,CAAC,OAAO,CAK5D,CAAC"}
@@ -146,4 +146,19 @@ export const validateReceiptIos = async (sku) => {
146
146
  const result = await ExpoIapModule.validateReceiptIos(sku);
147
147
  return result;
148
148
  };
149
+ /**
150
+ * Present the code redemption sheet for offer codes (iOS only).
151
+ * This allows users to redeem promotional codes for in-app purchases and subscriptions.
152
+ *
153
+ * Note: This only works on real devices, not simulators.
154
+ *
155
+ * @returns {Promise<boolean>} True if the sheet was presented successfully
156
+ * @throws {Error} If called on non-iOS platform or tvOS
157
+ */
158
+ export const presentCodeRedemptionSheet = () => {
159
+ if (Platform.OS !== 'ios') {
160
+ throw new Error('This method is only available on iOS');
161
+ }
162
+ return ExpoIapModule.presentCodeRedemptionSheet();
163
+ };
149
164
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,uBAAuB,EAAC,MAAM,IAAI,CAAC;AAQ3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,YAAY;AACZ;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C,EAAE;IACF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAA2B,EAAE;QACnE,OAAO,CACL,IAAI,IAAI,IAAI;YACZ,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,IAAI,IAAI;YACZ,eAAe,IAAI,IAAI;YACvB,UAAU,IAAI,IAAI,CACnB,CAAC;IACJ,CAAC,CAAC;IAEF,iEAAiE;IACjE,MAAM,6BAA6B,GAAG,CACpC,QAAyC,EACvB,EAAE;QACpB,8CAA8C;QAC9C,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChC,OAAO;gBACL,WAAW,EAAE,QAA2B;aACzC,CAAC;QACJ,CAAC;QAED,sDAAsD;QACtD,OAAO;YACL,WAAW,EAAE,QAA2B;SACzC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,uBAAuB,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC1C,yEAAyE;QACzE,MAAM,KAAK,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;QACtD,QAA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CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,cAAc,EAAE,CAAC;AACxC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAoB,EAAE;IACrE,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAmB,EAAE;IAChE,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EAMV,EAAE;IACH,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {purchaseUpdatedListener} from '..';\nimport {\n ProductPurchase,\n PurchaseError,\n Purchase,\n SubscriptionPurchase,\n} from '../ExpoIap.types';\nimport type {ProductStatusIos} from '../types/ExpoIapIos.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\nexport type TransactionEvent = {\n transaction?: ProductPurchase;\n error?: PurchaseError;\n};\n\n// Listeners\n/**\n * @deprecated Use `purchaseUpdatedListener` instead. This function will be removed in a future version.\n *\n * The `transactionUpdatedIos` function is redundant as it simply wraps `purchaseUpdatedListener`.\n * You can achieve the same functionality by using `purchaseUpdatedListener` directly.\n *\n * @example\n * // Instead of:\n * // transactionUpdatedIos((event) => { ... });\n *\n * // Use:\n * // purchaseUpdatedListener((purchase) => { ... });\n */\nexport const transactionUpdatedIos = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const isProductPurchase = (item: unknown): item is ProductPurchase => {\n return (\n item != null &&\n typeof item === 'object' &&\n 'id' in item &&\n 'transactionId' in item &&\n 'platform' in item\n );\n };\n\n // Helper function to safely convert Purchase to TransactionEvent\n const mapPurchaseToTransactionEvent = (\n purchase: Purchase | SubscriptionPurchase,\n ): TransactionEvent => {\n // Validate the purchase object before casting\n if (isProductPurchase(purchase)) {\n return {\n transaction: purchase as ProductPurchase,\n };\n }\n\n // Fallback: create a basic TransactionEvent structure\n return {\n transaction: purchase as ProductPurchase,\n };\n };\n\n return purchaseUpdatedListener((purchase) => {\n // Convert Purchase to TransactionEvent format for backward compatibility\n const event = mapPurchaseToTransactionEvent(purchase);\n listener(event);\n });\n};\n\n// Type guards\nexport function isProductIos<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => ExpoIapModule.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<boolean> =>\n ExpoIapModule.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatusIos[]> =>\n ExpoIapModule.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.latestTransaction(sku);\n\n/**\n *\n */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>\n ExpoIapModule.beginRefundRequest(sku);\n\n/**\n * Shows the system UI for managing subscriptions.\n * When the user changes subscription renewal status, the system will emit events to\n * purchaseUpdatedListener and transactionUpdatedIos listeners.\n * @returns {Promise<null>}\n */\nexport const showManageSubscriptions = (): Promise<null> =>\n ExpoIapModule.showManageSubscriptions();\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptIos = (): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getReceiptData();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<boolean>} True if the transaction is verified\n */\nexport const isTransactionVerified = (sku: string): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.isTransactionVerified(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<string>} JWS representation of the transaction\n */\nexport const getTransactionJws = (sku: string): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getTransactionJws(sku);\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: ProductPurchase;\n * }>}\n */\nexport const validateReceiptIos = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: ProductPurchase;\n}> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const result = await ExpoIapModule.validateReceiptIos(sku);\n return result;\n};\n"]}
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,uBAAuB,EAAC,MAAM,IAAI,CAAC;AAQ3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,YAAY;AACZ;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C,EAAE;IACF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAA2B,EAAE;QACnE,OAAO,CACL,IAAI,IAAI,IAAI;YACZ,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,IAAI,IAAI;YACZ,eAAe,IAAI,IAAI;YACvB,UAAU,IAAI,IAAI,CACnB,CAAC;IACJ,CAAC,CAAC;IAEF,iEAAiE;IACjE,MAAM,6BAA6B,GAAG,CACpC,QAAyC,EACvB,EAAE;QACpB,8CAA8C;QAC9C,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;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AAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAqB,EAAE;IAC/D,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {purchaseUpdatedListener} from '..';\nimport {\n ProductPurchase,\n PurchaseError,\n Purchase,\n SubscriptionPurchase,\n} from '../ExpoIap.types';\nimport type {ProductStatusIos} from '../types/ExpoIapIos.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\nexport type TransactionEvent = {\n transaction?: ProductPurchase;\n error?: PurchaseError;\n};\n\n// Listeners\n/**\n * @deprecated Use `purchaseUpdatedListener` instead. This function will be removed in a future version.\n *\n * The `transactionUpdatedIos` function is redundant as it simply wraps `purchaseUpdatedListener`.\n * You can achieve the same functionality by using `purchaseUpdatedListener` directly.\n *\n * @example\n * // Instead of:\n * // transactionUpdatedIos((event) => { ... });\n *\n * // Use:\n * // purchaseUpdatedListener((purchase) => { ... });\n */\nexport const transactionUpdatedIos = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const isProductPurchase = (item: unknown): item is ProductPurchase => {\n return (\n item != null &&\n typeof item === 'object' &&\n 'id' in item &&\n 'transactionId' in item &&\n 'platform' in item\n );\n };\n\n // Helper function to safely convert Purchase to TransactionEvent\n const mapPurchaseToTransactionEvent = (\n purchase: Purchase | SubscriptionPurchase,\n ): TransactionEvent => {\n // Validate the purchase object before casting\n if (isProductPurchase(purchase)) {\n return {\n transaction: purchase as ProductPurchase,\n };\n }\n\n // Fallback: create a basic TransactionEvent structure\n return {\n transaction: purchase as ProductPurchase,\n };\n };\n\n return purchaseUpdatedListener((purchase) => {\n // Convert Purchase to TransactionEvent format for backward compatibility\n const event = mapPurchaseToTransactionEvent(purchase);\n listener(event);\n });\n};\n\n// Type guards\nexport function isProductIos<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => ExpoIapModule.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<boolean> =>\n ExpoIapModule.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatusIos[]> =>\n ExpoIapModule.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.latestTransaction(sku);\n\n/**\n *\n */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>\n ExpoIapModule.beginRefundRequest(sku);\n\n/**\n * Shows the system UI for managing subscriptions.\n * When the user changes subscription renewal status, the system will emit events to\n * purchaseUpdatedListener and transactionUpdatedIos listeners.\n * @returns {Promise<null>}\n */\nexport const showManageSubscriptions = (): Promise<null> =>\n ExpoIapModule.showManageSubscriptions();\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptIos = (): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getReceiptData();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<boolean>} True if the transaction is verified\n */\nexport const isTransactionVerified = (sku: string): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.isTransactionVerified(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<string>} JWS representation of the transaction\n */\nexport const getTransactionJws = (sku: string): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getTransactionJws(sku);\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: ProductPurchase;\n * }>}\n */\nexport const validateReceiptIos = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: ProductPurchase;\n}> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const result = await ExpoIapModule.validateReceiptIos(sku);\n return result;\n};\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n * \n * Note: This only works on real devices, not simulators.\n * \n * @returns {Promise<boolean>} True if the sheet was presented successfully\n * @throws {Error} If called on non-iOS platform or tvOS\n */\nexport const presentCodeRedemptionSheet = (): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.presentCodeRedemptionSheet();\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.5.2",
3
+ "version": "2.5.3-rc.1",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1 +1 @@
1
- {"root":["./src/withIAP.ts"],"version":"5.8.3"}
1
+ {"root":["./src/withiap.ts"],"version":"5.8.3"}
@@ -92,3 +92,16 @@ export const acknowledgePurchaseAndroid = ({
92
92
  }): Promise<PurchaseResult | boolean | void> => {
93
93
  return ExpoIapModule.acknowledgePurchase(token, developerPayload);
94
94
  };
95
+
96
+ /**
97
+ * Open the Google Play Store to redeem offer codes (Android only).
98
+ * Note: Google Play does not provide a direct API to redeem codes within the app.
99
+ * This function opens the Play Store where users can manually enter their codes.
100
+ *
101
+ * @returns {Promise<void>}
102
+ */
103
+ export const openRedeemOfferCodeAndroid = async (): Promise<void> => {
104
+ return Linking.openURL(
105
+ `https://play.google.com/redeem?code=`
106
+ );
107
+ };
@@ -204,3 +204,19 @@ export const validateReceiptIos = async (
204
204
  const result = await ExpoIapModule.validateReceiptIos(sku);
205
205
  return result;
206
206
  };
207
+
208
+ /**
209
+ * Present the code redemption sheet for offer codes (iOS only).
210
+ * This allows users to redeem promotional codes for in-app purchases and subscriptions.
211
+ *
212
+ * Note: This only works on real devices, not simulators.
213
+ *
214
+ * @returns {Promise<boolean>} True if the sheet was presented successfully
215
+ * @throws {Error} If called on non-iOS platform or tvOS
216
+ */
217
+ export const presentCodeRedemptionSheet = (): Promise<boolean> => {
218
+ if (Platform.OS !== 'ios') {
219
+ throw new Error('This method is only available on iOS');
220
+ }
221
+ return ExpoIapModule.presentCodeRedemptionSheet();
222
+ };