react-native-purchases 7.21.0 → 8.0.0-beta.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.
@@ -10,7 +10,7 @@ Pod::Spec.new do |spec|
10
10
  spec.authors = package['author']
11
11
  spec.homepage = "https://github.com/RevenueCat/react-native-purchases"
12
12
  spec.license = package['license']
13
- spec.platform = :ios, "11.0"
13
+ spec.platform = :ios, "13.0"
14
14
 
15
15
  spec.source = { :git => "https://github.com/RevenueCat/react-native-purchases.git" }
16
16
  spec.source_files = "ios/**/*.{h,m,swift}"
@@ -25,6 +25,6 @@ Pod::Spec.new do |spec|
25
25
  ]
26
26
 
27
27
  spec.dependency "React-Core"
28
- spec.dependency "PurchasesHybridCommon", '9.7.1'
28
+ spec.dependency "PurchasesHybridCommon", '10.0.0-beta.1'
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 '7.21.0'
32
+ versionName '8.0.0-beta.1'
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:9.7.1'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:9.8.0'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -45,7 +45,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
45
45
  private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
46
46
  private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
47
47
  public static final String PLATFORM_NAME = "react-native";
48
- public static final String PLUGIN_VERSION = "7.21.0";
48
+ public static final String PLUGIN_VERSION = "8.0.0-beta.1";
49
49
 
50
50
  private final ReactApplicationContext reactContext;
51
51
 
@@ -82,7 +82,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
82
82
  @ReactMethod
83
83
  public void setupPurchases(String apiKey, @Nullable String appUserID,
84
84
  boolean observerMode, @Nullable String userDefaultsSuiteName,
85
- @Nullable Boolean usesStoreKit2IfAvailable, boolean useAmazon,
85
+ @Nullable String storeKitVersion, boolean useAmazon,
86
86
  boolean shouldShowInAppMessagesAutomatically,
87
87
  @Nullable String entitlementVerificationMode) {
88
88
  PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
@@ -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 } 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 } from '@revenuecat/purchases-typescript-internal';
2
2
  export { PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult } from '@revenuecat/purchases-typescript-internal';
3
3
  export default class Purchases {
4
4
  /**
@@ -76,6 +76,12 @@ export default class Purchases {
76
76
  * @enum {string}
77
77
  */
78
78
  static VERIFICATION_RESULT: typeof VERIFICATION_RESULT;
79
+ /**
80
+ * Enum of StoreKit version.
81
+ * @readonly
82
+ * @enum {string}
83
+ */
84
+ static STOREKIT_VERSION: typeof STOREKIT_VERSION;
79
85
  /**
80
86
  * @internal
81
87
  */
@@ -89,7 +95,7 @@ export default class Purchases {
89
95
  * @param {String} apiKey RevenueCat API Key. Needs to be a String
90
96
  * @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
91
97
  * @param {boolean} [observerMode=false] An optional boolean. Set this to TRUE if you have your own IAP implementation and want to use only RevenueCat's backend. Default is FALSE.
92
- * @param {boolean} [usesStoreKit2IfAvailable=false] DEPRECATED. An optional boolean. iOS-only. Defaults to FALSE. Setting this to TRUE will enable StoreKit2 on compatible devices.
98
+ * @param {STOREKIT_VERSION} [storeKitVersion=STOREKIT_2] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 15+. StoreKit 1 will be used for previous iOS versions regardless of this setting.
93
99
  * We recommend not using this parameter, letting RevenueCat decide for you which StoreKit implementation to use.
94
100
  * @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
95
101
  * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
@@ -97,7 +103,7 @@ export default class Purchases {
97
103
  * Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
98
104
  * Default is null, which will make the SDK use standardUserDefaults.
99
105
  */
100
- static configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode }: PurchasesConfiguration): void;
106
+ static configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode }: PurchasesConfiguration): void;
101
107
  /**
102
108
  * @deprecated, configure behavior through the RevenueCat dashboard instead.
103
109
  * If an user tries to purchase a product that is active on the current app store account,
@@ -323,6 +329,22 @@ export default class Purchases {
323
329
  * syncing purchases.
324
330
  */
325
331
  static syncObserverModeAmazonPurchase(productID: string, receiptID: string, amazonUserID: string, isoCurrencyCode?: string | null, price?: number | null): Promise<void>;
332
+ /**
333
+ * iOS only. Always returns an error on iOS < 15.
334
+ *
335
+ * Use this method only if you already have your own IAP implementation using StoreKit 2 and want to use
336
+ * RevenueCat's backend. If you are using StoreKit 1 for your implementation, you do not need this method.
337
+ *
338
+ * You only need to use this method with *new* purchases. Subscription updates are observed automatically.
339
+ *
340
+ * Important: This should only be used if you have enabled observer mode during SDK configuration.
341
+ *
342
+ * @warning You need to finish the transaction yourself after calling this method.
343
+ *
344
+ * @param {string} productID Product ID that was just purchased
345
+ * @returns {Promise<PurchasesStoreTransaction>} If there was a transacton found and handled for the provided product ID.
346
+ */
347
+ static handleObserverModeTransaction(productID: string): Promise<PurchasesStoreTransaction>;
326
348
  /**
327
349
  * @deprecated, use enableAdServicesAttributionTokenCollection instead.
328
350
  * Enable automatic collection of Apple Search Ad attribution. Disabled by default
package/dist/purchases.js CHANGED
@@ -73,7 +73,7 @@ var Purchases = /** @class */ (function () {
73
73
  * @param {String} apiKey RevenueCat API Key. Needs to be a String
74
74
  * @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
75
75
  * @param {boolean} [observerMode=false] An optional boolean. Set this to TRUE if you have your own IAP implementation and want to use only RevenueCat's backend. Default is FALSE.
76
- * @param {boolean} [usesStoreKit2IfAvailable=false] DEPRECATED. An optional boolean. iOS-only. Defaults to FALSE. Setting this to TRUE will enable StoreKit2 on compatible devices.
76
+ * @param {STOREKIT_VERSION} [storeKitVersion=STOREKIT_2] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 15+. StoreKit 1 will be used for previous iOS versions regardless of this setting.
77
77
  * We recommend not using this parameter, letting RevenueCat decide for you which StoreKit implementation to use.
78
78
  * @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
79
79
  * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
@@ -82,14 +82,14 @@ var Purchases = /** @class */ (function () {
82
82
  * Default is null, which will make the SDK use standardUserDefaults.
83
83
  */
84
84
  Purchases.configure = function (_a) {
85
- var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.observerMode, observerMode = _c === void 0 ? false : _c, userDefaultsSuiteName = _a.userDefaultsSuiteName, _d = _a.usesStoreKit2IfAvailable, usesStoreKit2IfAvailable = _d === void 0 ? false : _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;
85
+ var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.observerMode, observerMode = _c === void 0 ? false : _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;
86
86
  if (apiKey === undefined || typeof apiKey !== "string") {
87
87
  throw new Error("Invalid API key. It must be called with an Object: configure({apiKey: \"key\"})");
88
88
  }
89
89
  if (appUserID !== null && typeof appUserID !== "undefined" && typeof appUserID !== "string") {
90
90
  throw new Error("appUserID needs to be a string");
91
91
  }
92
- RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode);
92
+ RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName, storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode);
93
93
  };
94
94
  /**
95
95
  * @deprecated, configure behavior through the RevenueCat dashboard instead.
@@ -591,6 +591,36 @@ var Purchases = /** @class */ (function () {
591
591
  });
592
592
  });
593
593
  };
594
+ /**
595
+ * iOS only. Always returns an error on iOS < 15.
596
+ *
597
+ * Use this method only if you already have your own IAP implementation using StoreKit 2 and want to use
598
+ * RevenueCat's backend. If you are using StoreKit 1 for your implementation, you do not need this method.
599
+ *
600
+ * You only need to use this method with *new* purchases. Subscription updates are observed automatically.
601
+ *
602
+ * Important: This should only be used if you have enabled observer mode during SDK configuration.
603
+ *
604
+ * @warning You need to finish the transaction yourself after calling this method.
605
+ *
606
+ * @param {string} productID Product ID that was just purchased
607
+ * @returns {Promise<PurchasesStoreTransaction>} If there was a transacton found and handled for the provided product ID.
608
+ */
609
+ Purchases.handleObserverModeTransaction = function (productID) {
610
+ return __awaiter(this, void 0, void 0, function () {
611
+ return __generator(this, function (_a) {
612
+ switch (_a.label) {
613
+ case 0: return [4 /*yield*/, Purchases.throwIfAndroidPlatform()];
614
+ case 1:
615
+ _a.sent();
616
+ return [4 /*yield*/, Purchases.throwIfNotConfigured()];
617
+ case 2:
618
+ _a.sent();
619
+ return [2 /*return*/, RNPurchases.handleObserverModeTransactionForProductID(productID)];
620
+ }
621
+ });
622
+ });
623
+ };
594
624
  /**
595
625
  * @deprecated, use enableAdServicesAttributionTokenCollection instead.
596
626
  * Enable automatic collection of Apple Search Ad attribution. Disabled by default
@@ -1466,6 +1496,12 @@ var Purchases = /** @class */ (function () {
1466
1496
  * @enum {string}
1467
1497
  */
1468
1498
  Purchases.VERIFICATION_RESULT = purchases_typescript_internal_1.VERIFICATION_RESULT;
1499
+ /**
1500
+ * Enum of StoreKit version.
1501
+ * @readonly
1502
+ * @enum {string}
1503
+ */
1504
+ Purchases.STOREKIT_VERSION = purchases_typescript_internal_1.STOREKIT_VERSION;
1469
1505
  /**
1470
1506
  * @internal
1471
1507
  */
package/ios/RNPurchases.m CHANGED
@@ -41,7 +41,7 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
41
41
  appUserID:(nullable NSString *)appUserID
42
42
  observerMode:(BOOL)observerMode
43
43
  userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
44
- usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable
44
+ storeKitVersion:(nullable NSString *)storeKitVersion
45
45
  useAmazon:(BOOL)useAmazon
46
46
  shouldShowInAppMessagesAutomatically:(BOOL)shouldShowInAppMessagesAutomatically
47
47
  entitlementVerificationMode:(nullable NSString *)entitlementVerificationMode) {
@@ -51,9 +51,9 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
51
51
  userDefaultsSuiteName:userDefaultsSuiteName
52
52
  platformFlavor:self.platformFlavor
53
53
  platformFlavorVersion:self.platformFlavorVersion
54
- usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
55
- dangerousSettings:nil
56
- shouldShowInAppMessagesAutomatically:shouldShowInAppMessagesAutomatically
54
+ storeKitVersion:storeKitVersion
55
+ dangerousSettings:nil
56
+ shouldShowInAppMessagesAutomatically:shouldShowInAppMessagesAutomatically
57
57
  verificationMode:entitlementVerificationMode];
58
58
  purchases.delegate = self;
59
59
  }
@@ -232,6 +232,22 @@ static void logUnavailablePresentCodeRedemptionSheet() {
232
232
  NSLog(@"[Purchases] Warning: tried to present codeRedemptionSheet, but it's only available on iOS 14.0 or greater.");
233
233
  }
234
234
 
235
+ RCT_EXPORT_METHOD(handleObserverModeTransactionForProductID:(nonnull NSString *)productID
236
+ resolve:(RCTPromiseResolveBlock)resolve
237
+ reject:(RCTPromiseRejectBlock)reject) {
238
+ if (@available(iOS 15.0, *)) {
239
+ [RCCommonFunctionality handleObserverModeTransactionForProductID:productID
240
+ completion:[self getResponseCompletionBlockWithResolve:resolve
241
+ reject:reject]];
242
+ } else {
243
+ NSString* description = @"Tried to handle Observer Mode transaction, but it's only available on iOS 15.0 or greater.";
244
+ NSError* error = [[NSError alloc] initWithDomain: RCPurchasesErrorCodeDomain
245
+ code: RCUnsupportedError
246
+ userInfo: @{NSLocalizedDescriptionKey : description}];
247
+ reject([NSString stringWithFormat:@"%ld", (long) error.code], [error localizedDescription], error);
248
+ }
249
+ }
250
+
235
251
  #pragma mark - Subscriber Attributes
236
252
 
237
253
  RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString) {
@@ -472,7 +488,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
472
488
  }
473
489
 
474
490
  - (NSString *)platformFlavorVersion {
475
- return @"7.21.0";
491
+ return @"8.0.0-beta.1";
476
492
  }
477
493
 
478
494
  @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": "7.21.0",
4
+ "version": "8.0.0-beta.1",
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",
@@ -99,6 +99,6 @@
99
99
  ]
100
100
  },
101
101
  "dependencies": {
102
- "@revenuecat/purchases-typescript-internal": "9.7.1"
102
+ "@revenuecat/purchases-typescript-internal": "10.0.0-beta.1"
103
103
  }
104
104
  }