react-native-purchases 8.4.2 → 8.5.0

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.
@@ -25,6 +25,6 @@ Pod::Spec.new do |spec|
25
25
  ]
26
26
 
27
27
  spec.dependency "React-Core"
28
- spec.dependency "PurchasesHybridCommon", '13.13.0'
28
+ spec.dependency "PurchasesHybridCommon", '13.14.0'
29
29
  spec.swift_version = '5.7'
30
30
  end
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '8.4.2'
32
+ versionName '8.5.0'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -121,6 +121,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
121
121
  dependencies {
122
122
  //noinspection GradleDynamicVersion
123
123
  api 'com.facebook.react:react-native:+'
124
- implementation 'com.revenuecat.purchases:purchases-hybrid-common:13.13.0'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:13.14.0'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -47,7 +47,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
47
47
  private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
48
48
  private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
49
49
  public static final String PLATFORM_NAME = "react-native";
50
- public static final String PLUGIN_VERSION = "8.4.2";
50
+ public static final String PLUGIN_VERSION = "8.5.0";
51
51
 
52
52
  private final ReactApplicationContext reactContext;
53
53
 
@@ -87,7 +87,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
87
87
  @Nullable String storeKitVersion, boolean useAmazon,
88
88
  boolean shouldShowInAppMessagesAutomatically,
89
89
  @Nullable String entitlementVerificationMode,
90
- boolean pendingTransactionsForPrepaidPlansEnabled) {
90
+ boolean pendingTransactionsForPrepaidPlansEnabled,
91
+ boolean diagnosticsEnabled) {
91
92
  PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
92
93
  Store store = Store.PLAY_STORE;
93
94
  if (useAmazon) {
@@ -103,7 +104,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
103
104
  new DangerousSettings(),
104
105
  shouldShowInAppMessagesAutomatically,
105
106
  entitlementVerificationMode,
106
- pendingTransactionsForPrepaidPlansEnabled
107
+ pendingTransactionsForPrepaidPlansEnabled,
108
+ diagnosticsEnabled
107
109
  );
108
110
  Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
109
111
  }
@@ -510,6 +512,16 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
510
512
  promise.resolve(null);
511
513
  }
512
514
 
515
+ @ReactMethod
516
+ public void isWebPurchaseRedemptionURL(String urlString, final Promise promise) {
517
+ promise.resolve(CommonKt.isWebPurchaseRedemptionURL(urlString));
518
+ }
519
+
520
+ @ReactMethod
521
+ public void redeemWebPurchase(String urlString, final Promise promise) {
522
+ CommonKt.redeemWebPurchase(urlString, getOnResult(promise));
523
+ }
524
+
513
525
  // endregion
514
526
 
515
527
  //================================================================================
@@ -1,4 +1,4 @@
1
- import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError, CustomerInfo, PurchasesEntitlementInfo, PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo, PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, STOREKIT_VERSION, PurchasesStoreTransaction, PurchasesOffering, PURCHASES_ARE_COMPLETED_BY_TYPE, PurchasesWinBackOffer } from "@revenuecat/purchases-typescript-internal";
1
+ import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError, CustomerInfo, PurchasesEntitlementInfo, PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo, PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, STOREKIT_VERSION, PurchasesStoreTransaction, PurchasesOffering, PURCHASES_ARE_COMPLETED_BY_TYPE, PurchasesWinBackOffer, WebPurchaseRedemption, WebPurchaseRedemptionResult } from "@revenuecat/purchases-typescript-internal";
2
2
  export { PURCHASE_TYPE, PurchasesAreCompletedBy, PurchasesAreCompletedByMyApp, PURCHASES_ARE_COMPLETED_BY_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, STOREKIT_VERSION, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, } from "@revenuecat/purchases-typescript-internal";
3
3
  export default class Purchases {
4
4
  /**
@@ -103,15 +103,16 @@ export default class Purchases {
103
103
  * @param {PurchasesAreCompletedBy} [purchasesAreCompletedBy=PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT] Set this to an instance of PurchasesAreCompletedByMyApp if you have your own IAP implementation and want to use only RevenueCat's backend. Default is PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT.
104
104
  * @param {STOREKIT_VERSION} [storeKitVersion=DEFAULT] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 16+. StoreKit 1 will be used for previous iOS versions regardless of this setting.
105
105
  * @param {ENTITLEMENT_VERIFICATION_MODE} [entitlementVerificationMode=ENTITLEMENT_VERIFICATION_MODE.DISABLED] Sets the entitlement verifciation mode to use. For more details, check https://rev.cat/trusted-entitlements
106
- * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
106
+ * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to true to enable Amazon on compatible devices.
107
107
  * @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
108
108
  * Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
109
109
  * Default is null, which will make the SDK use standardUserDefaults.
110
- * @param {boolean} [pendingTransactionsForPrepaidPlansEnabled=false] An optional boolean. Android-only. Set this to TRUE to enable pending transactions for prepaid subscriptions in Google Play.
110
+ * @param {boolean} [pendingTransactionsForPrepaidPlansEnabled=false] An optional boolean. Android-only. Set this to true to enable pending transactions for prepaid subscriptions in Google Play.
111
+ * @param {boolean} [diagnosticsEnabled=false] An optional boolean. Set this to true to enable SDK diagnostics.
111
112
  *
112
113
  * @warning If you use purchasesAreCompletedBy=PurchasesAreCompletedByMyApp, you must also provide a value for storeKitVersion.
113
114
  */
114
- static configure({ apiKey, appUserID, purchasesAreCompletedBy, userDefaultsSuiteName, storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled, }: PurchasesConfiguration): void;
115
+ static configure({ apiKey, appUserID, purchasesAreCompletedBy, userDefaultsSuiteName, storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled, diagnosticsEnabled, }: PurchasesConfiguration): void;
115
116
  /**
116
117
  * @deprecated, configure behavior through the RevenueCat dashboard (app.revenuecat.com) instead.
117
118
  * If an user tries to purchase a product that is active on the current app store account,
@@ -757,6 +758,19 @@ export default class Purchases {
757
758
  * @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
758
759
  */
759
760
  static showInAppMessages(messageTypes?: IN_APP_MESSAGE_TYPE[]): Promise<void>;
761
+ /**
762
+ * Parses the given URL into a [WebPurchaseRedemption] object that can be used to redeem web purchases
763
+ * @param urlString The Redemption Link URL as a string
764
+ * @returns {Promise<WebPurchaseRedemption>} A WebPurchaseRedemption object that can be used to redeem the link using [redeemWebPurchase].
765
+ */
766
+ static parseAsWebPurchaseRedemption(urlString: string): Promise<WebPurchaseRedemption | null>;
767
+ /**
768
+ * Redeems the web purchase associated with the Redemption Link obtained with [parseAsWebPurchaseRedemption].
769
+ * @param webPurchaseRedemption The WebPurchaseRedemption object obtained from [parseAsWebPurchaseRedemption].
770
+ * @returns {Promise<WebPurchaseRedemptionResult>} The result of the redemption process. Can throw if an invalid
771
+ * WebPurchaseRedemption parameter is passed or Purchases is not configured.
772
+ */
773
+ static redeemWebPurchase(webPurchaseRedemption: WebPurchaseRedemption): Promise<WebPurchaseRedemptionResult>;
760
774
  /**
761
775
  * Check if configure has finished and Purchases has been configured.
762
776
  *
package/dist/purchases.js CHANGED
@@ -77,16 +77,17 @@ var Purchases = /** @class */ (function () {
77
77
  * @param {PurchasesAreCompletedBy} [purchasesAreCompletedBy=PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT] Set this to an instance of PurchasesAreCompletedByMyApp if you have your own IAP implementation and want to use only RevenueCat's backend. Default is PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT.
78
78
  * @param {STOREKIT_VERSION} [storeKitVersion=DEFAULT] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 16+. StoreKit 1 will be used for previous iOS versions regardless of this setting.
79
79
  * @param {ENTITLEMENT_VERIFICATION_MODE} [entitlementVerificationMode=ENTITLEMENT_VERIFICATION_MODE.DISABLED] Sets the entitlement verifciation mode to use. For more details, check https://rev.cat/trusted-entitlements
80
- * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
80
+ * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to true to enable Amazon on compatible devices.
81
81
  * @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
82
82
  * Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
83
83
  * Default is null, which will make the SDK use standardUserDefaults.
84
- * @param {boolean} [pendingTransactionsForPrepaidPlansEnabled=false] An optional boolean. Android-only. Set this to TRUE to enable pending transactions for prepaid subscriptions in Google Play.
84
+ * @param {boolean} [pendingTransactionsForPrepaidPlansEnabled=false] An optional boolean. Android-only. Set this to true to enable pending transactions for prepaid subscriptions in Google Play.
85
+ * @param {boolean} [diagnosticsEnabled=false] An optional boolean. Set this to true to enable SDK diagnostics.
85
86
  *
86
87
  * @warning If you use purchasesAreCompletedBy=PurchasesAreCompletedByMyApp, you must also provide a value for storeKitVersion.
87
88
  */
88
89
  Purchases.configure = function (_a) {
89
- var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.purchasesAreCompletedBy, purchasesAreCompletedBy = _c === void 0 ? purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT : _c, userDefaultsSuiteName = _a.userDefaultsSuiteName, _d = _a.storeKitVersion, storeKitVersion = _d === void 0 ? purchases_typescript_internal_1.STOREKIT_VERSION.DEFAULT : _d, _e = _a.useAmazon, useAmazon = _e === void 0 ? false : _e, _f = _a.shouldShowInAppMessagesAutomatically, shouldShowInAppMessagesAutomatically = _f === void 0 ? true : _f, _g = _a.entitlementVerificationMode, entitlementVerificationMode = _g === void 0 ? purchases_typescript_internal_1.ENTITLEMENT_VERIFICATION_MODE.DISABLED : _g, _h = _a.pendingTransactionsForPrepaidPlansEnabled, pendingTransactionsForPrepaidPlansEnabled = _h === void 0 ? false : _h;
90
+ var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.purchasesAreCompletedBy, purchasesAreCompletedBy = _c === void 0 ? purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT : _c, userDefaultsSuiteName = _a.userDefaultsSuiteName, _d = _a.storeKitVersion, storeKitVersion = _d === void 0 ? purchases_typescript_internal_1.STOREKIT_VERSION.DEFAULT : _d, _e = _a.useAmazon, useAmazon = _e === void 0 ? false : _e, _f = _a.shouldShowInAppMessagesAutomatically, shouldShowInAppMessagesAutomatically = _f === void 0 ? true : _f, _g = _a.entitlementVerificationMode, entitlementVerificationMode = _g === void 0 ? purchases_typescript_internal_1.ENTITLEMENT_VERIFICATION_MODE.DISABLED : _g, _h = _a.pendingTransactionsForPrepaidPlansEnabled, pendingTransactionsForPrepaidPlansEnabled = _h === void 0 ? false : _h, _j = _a.diagnosticsEnabled, diagnosticsEnabled = _j === void 0 ? false : _j;
90
91
  if (apiKey === undefined || typeof apiKey !== "string") {
91
92
  throw new Error('Invalid API key. It must be called with an Object: configure({apiKey: "key"})');
92
93
  }
@@ -113,7 +114,7 @@ var Purchases = /** @class */ (function () {
113
114
  console.warn("Warning: You should provide the specific StoreKit version you're using in your implementation when configuring PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP, and not rely on the DEFAULT.");
114
115
  }
115
116
  }
116
- RNPurchases.setupPurchases(apiKey, appUserID, purchasesCompletedByToUse, userDefaultsSuiteName, storeKitVersionToUse, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled);
117
+ RNPurchases.setupPurchases(apiKey, appUserID, purchasesCompletedByToUse, userDefaultsSuiteName, storeKitVersionToUse, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled, diagnosticsEnabled);
117
118
  };
118
119
  /**
119
120
  * @deprecated, configure behavior through the RevenueCat dashboard (app.revenuecat.com) instead.
@@ -1593,6 +1594,39 @@ var Purchases = /** @class */ (function () {
1593
1594
  });
1594
1595
  });
1595
1596
  };
1597
+ /**
1598
+ * Parses the given URL into a [WebPurchaseRedemption] object that can be used to redeem web purchases
1599
+ * @param urlString The Redemption Link URL as a string
1600
+ * @returns {Promise<WebPurchaseRedemption>} A WebPurchaseRedemption object that can be used to redeem the link using [redeemWebPurchase].
1601
+ */
1602
+ Purchases.parseAsWebPurchaseRedemption = function (urlString) {
1603
+ return __awaiter(this, void 0, void 0, function () {
1604
+ return __generator(this, function (_a) {
1605
+ if (RNPurchases.isWebPurchaseRedemptionURL(urlString)) {
1606
+ return [2 /*return*/, { redemptionLink: urlString }];
1607
+ }
1608
+ return [2 /*return*/, null];
1609
+ });
1610
+ });
1611
+ };
1612
+ /**
1613
+ * Redeems the web purchase associated with the Redemption Link obtained with [parseAsWebPurchaseRedemption].
1614
+ * @param webPurchaseRedemption The WebPurchaseRedemption object obtained from [parseAsWebPurchaseRedemption].
1615
+ * @returns {Promise<WebPurchaseRedemptionResult>} The result of the redemption process. Can throw if an invalid
1616
+ * WebPurchaseRedemption parameter is passed or Purchases is not configured.
1617
+ */
1618
+ Purchases.redeemWebPurchase = function (webPurchaseRedemption) {
1619
+ return __awaiter(this, void 0, void 0, function () {
1620
+ return __generator(this, function (_a) {
1621
+ switch (_a.label) {
1622
+ case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
1623
+ case 1:
1624
+ _a.sent();
1625
+ return [2 /*return*/, RNPurchases.redeemWebPurchase(webPurchaseRedemption.redemptionLink)];
1626
+ }
1627
+ });
1628
+ });
1629
+ };
1596
1630
  /**
1597
1631
  * Check if configure has finished and Purchases has been configured.
1598
1632
  *
package/ios/RNPurchases.m CHANGED
@@ -45,7 +45,8 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
45
45
  useAmazon:(BOOL)useAmazon
46
46
  shouldShowInAppMessagesAutomatically:(BOOL)shouldShowInAppMessagesAutomatically
47
47
  entitlementVerificationMode:(nullable NSString *)entitlementVerificationMode
48
- pendingTransactionsForPrepaidPlansEnabled:(BOOL)pendingTransactionsForPrepaidPlansEnabled) {
48
+ pendingTransactionsForPrepaidPlansEnabled:(BOOL)pendingTransactionsForPrepaidPlansEnabled
49
+ diagnosticsEnabled:(BOOL)diagnosticsEnabled) {
49
50
  RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey
50
51
  appUserID:appUserID
51
52
  purchasesAreCompletedBy:purchasesAreCompletedBy
@@ -55,7 +56,8 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
55
56
  storeKitVersion:storeKitVersion
56
57
  dangerousSettings:nil
57
58
  shouldShowInAppMessagesAutomatically:shouldShowInAppMessagesAutomatically
58
- verificationMode:entitlementVerificationMode];
59
+ verificationMode:entitlementVerificationMode
60
+ diagnosticsEnabled:diagnosticsEnabled];
59
61
  purchases.delegate = self;
60
62
  }
61
63
 
@@ -495,6 +497,20 @@ RCT_EXPORT_METHOD(setLogHandler) {
495
497
  }];
496
498
  }
497
499
 
500
+ RCT_EXPORT_METHOD(isWebPurchaseRedemptionURL:(NSString *)urlString
501
+ resolve:(RCTPromiseResolveBlock)resolve
502
+ reject:(RCTPromiseRejectBlock)reject) {
503
+ resolve(@([RCCommonFunctionality isWebPurchaseRedemptionURL:urlString]));
504
+ }
505
+
506
+ RCT_EXPORT_METHOD(redeemWebPurchase:(NSString *)urlString
507
+ resolve:(RCTPromiseResolveBlock)resolve
508
+ reject:(RCTPromiseRejectBlock)reject) {
509
+ [RCCommonFunctionality redeemWebPurchaseWithUrlString:urlString
510
+ completion:[self getResponseCompletionBlockWithResolve:resolve
511
+ reject:reject]];
512
+ }
513
+
498
514
  #pragma mark -
499
515
  #pragma mark PurchasesAreCompletedBy Helper Functions
500
516
  RCT_EXPORT_METHOD(recordPurchaseForProductID:(nonnull NSString *)productID
@@ -572,7 +588,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
572
588
  }
573
589
 
574
590
  - (NSString *)platformFlavorVersion {
575
- return @"8.4.2";
591
+ return @"8.5.0";
576
592
  }
577
593
 
578
594
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-purchases",
3
3
  "title": "React Native Purchases",
4
- "version": "8.4.2",
4
+ "version": "8.5.0",
5
5
  "description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -100,6 +100,6 @@
100
100
  ]
101
101
  },
102
102
  "dependencies": {
103
- "@revenuecat/purchases-typescript-internal": "13.13.0"
103
+ "@revenuecat/purchases-typescript-internal": "13.14.0"
104
104
  }
105
105
  }