react-native-purchases 5.0.0-beta.2 → 5.0.0-beta.3

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.
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '5.0.0-beta.2'
32
+ versionName '5.0.0-beta.3'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '5.0.0-beta.1'
32
+ versionName '5.0.0-beta.2'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -16,6 +16,7 @@ import com.facebook.react.bridge.WritableArray;
16
16
  import com.facebook.react.modules.core.DeviceEventManagerModule;
17
17
  import com.revenuecat.purchases.CustomerInfo;
18
18
  import com.revenuecat.purchases.Purchases;
19
+ import com.revenuecat.purchases.Store;
19
20
  import com.revenuecat.purchases.common.PlatformInfo;
20
21
  import com.revenuecat.purchases.hybridcommon.CommonKt;
21
22
  import com.revenuecat.purchases.hybridcommon.ErrorContainer;
@@ -79,9 +80,13 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
79
80
  @ReactMethod
80
81
  public void setupPurchases(String apiKey, @Nullable String appUserID,
81
82
  boolean observerMode, @Nullable String userDefaultsSuiteName,
82
- @Nullable Boolean usesStoreKit2IfAvailable) {
83
+ @Nullable Boolean usesStoreKit2IfAvailable, boolean useAmazon) {
83
84
  PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
84
- CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo);
85
+ Store store = Store.PLAY_STORE;
86
+ if (useAmazon) {
87
+ store = Store.AMAZON;
88
+ }
89
+ CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo, store);
85
90
  Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
86
91
  }
87
92
 
@@ -16,6 +16,7 @@ import com.facebook.react.bridge.WritableArray;
16
16
  import com.facebook.react.modules.core.DeviceEventManagerModule;
17
17
  import com.revenuecat.purchases.CustomerInfo;
18
18
  import com.revenuecat.purchases.Purchases;
19
+ import com.revenuecat.purchases.Store;
19
20
  import com.revenuecat.purchases.common.PlatformInfo;
20
21
  import com.revenuecat.purchases.hybridcommon.CommonKt;
21
22
  import com.revenuecat.purchases.hybridcommon.ErrorContainer;
@@ -79,10 +80,14 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
79
80
  @ReactMethod
80
81
  public void setupPurchases(String apiKey, @Nullable String appUserID,
81
82
  boolean observerMode, @Nullable String userDefaultsSuiteName,
82
- @Nullable Boolean usesStoreKit2IfAvailable) {
83
+ @Nullable Boolean usesStoreKit2IfAvailable, boolean useAmazon) {
83
84
  PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
84
- CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo);
85
- Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
85
+ Store store = Store.PLAY_STORE;
86
+ if (useAmazon) {
87
+ store = Store.AMAZON;
88
+ }
89
+ CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo, store);
90
+ Purchases.getSharedInstance().setUpdatedPurchaserInfoListener(this);
86
91
  }
87
92
 
88
93
  @ReactMethod
@@ -62,6 +62,17 @@ export interface LogInResult {
62
62
  */
63
63
  readonly created: boolean;
64
64
  }
65
+ /**
66
+ * Holds parameters to initialize the SDK.
67
+ */
68
+ export interface PurchasesConfiguration {
69
+ apiKey: string;
70
+ appUserID?: string | null;
71
+ observerMode?: boolean;
72
+ userDefaultsSuiteName?: string;
73
+ usesStoreKit2IfAvailable?: boolean;
74
+ useAmazon?: boolean;
75
+ }
65
76
  export default class Purchases {
66
77
  /**
67
78
  * Supported SKU types.
@@ -111,11 +122,12 @@ export default class Purchases {
111
122
  * @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
112
123
  * @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.
113
124
  * @param {boolean} [usesStoreKit2IfAvailable=false] An optional boolean. iOS-only. Set this to TRUE to enable StoreKit2 on compatible devices.
125
+ * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
114
126
  * @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
115
127
  * Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
116
128
  * Default is null, which will make the SDK use standardUserDefaults.
117
129
  */
118
- static configure(apiKey: string, appUserID?: string | null, observerMode?: boolean, userDefaultsSuiteName?: string, usesStoreKit2IfAvailable?: boolean): void;
130
+ static configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon }: PurchasesConfiguration): void;
119
131
  /**
120
132
  * @deprecated, configure behavior through the RevenueCat dashboard instead.
121
133
  * If an user tries to purchase a product that is active on the current app store account,
@@ -234,7 +246,7 @@ export default class Purchases {
234
246
  * @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code, and an
235
247
  * userInfo object with more information. The promise will be also be rejected if setup has not been called yet.
236
248
  */
237
- static restoreTransactions(): Promise<CustomerInfo>;
249
+ static restorePurchases(): Promise<CustomerInfo>;
238
250
  /**
239
251
  * Get the appUserID
240
252
  * @returns {Promise<string>} The app user id in a promise
package/dist/purchases.js CHANGED
@@ -102,17 +102,20 @@ var Purchases = /** @class */ (function () {
102
102
  * @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
103
103
  * @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.
104
104
  * @param {boolean} [usesStoreKit2IfAvailable=false] An optional boolean. iOS-only. Set this to TRUE to enable StoreKit2 on compatible devices.
105
+ * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
105
106
  * @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
106
107
  * Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
107
108
  * Default is null, which will make the SDK use standardUserDefaults.
108
109
  */
109
- Purchases.configure = function (apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable) {
110
- if (observerMode === void 0) { observerMode = false; }
111
- if (usesStoreKit2IfAvailable === void 0) { usesStoreKit2IfAvailable = false; }
110
+ Purchases.configure = function (_a) {
111
+ 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;
112
+ if (apiKey === undefined || typeof apiKey !== "string") {
113
+ throw new Error("Invalid API key. It must be called with an Object: configure({apiKey: \"key\"})");
114
+ }
112
115
  if (appUserID !== null && typeof appUserID !== "undefined" && typeof appUserID !== "string") {
113
116
  throw new Error("appUserID needs to be a string");
114
117
  }
115
- RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable);
118
+ RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon);
116
119
  };
117
120
  /**
118
121
  * @deprecated, configure behavior through the RevenueCat dashboard instead.
@@ -373,14 +376,14 @@ var Purchases = /** @class */ (function () {
373
376
  * @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code, and an
374
377
  * userInfo object with more information. The promise will be also be rejected if setup has not been called yet.
375
378
  */
376
- Purchases.restoreTransactions = function () {
379
+ Purchases.restorePurchases = function () {
377
380
  return __awaiter(this, void 0, void 0, function () {
378
381
  return __generator(this, function (_a) {
379
382
  switch (_a.label) {
380
383
  case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
381
384
  case 1:
382
385
  _a.sent();
383
- return [2 /*return*/, RNPurchases.restoreTransactions()];
386
+ return [2 /*return*/, RNPurchases.restorePurchases()];
384
387
  }
385
388
  });
386
389
  });
package/ios/RNPurchases.m CHANGED
@@ -38,15 +38,16 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
38
38
  appUserID:(nullable NSString *)appUserID
39
39
  observerMode:(BOOL)observerMode
40
40
  userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
41
- usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable) {
41
+ usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable
42
+ useAmazon:(BOOL)useAmazon) {
42
43
  RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey
43
- appUserID:appUserID
44
- observerMode:observerMode
45
- userDefaultsSuiteName:userDefaultsSuiteName
46
- platformFlavor:self.platformFlavor
47
- platformFlavorVersion:self.platformFlavorVersion
44
+ appUserID:appUserID
45
+ observerMode:observerMode
46
+ userDefaultsSuiteName:userDefaultsSuiteName
47
+ platformFlavor:self.platformFlavor
48
+ platformFlavorVersion:self.platformFlavorVersion
48
49
  usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
49
- dangerousSettings:nil];
50
+ dangerousSettings:nil];
50
51
  purchases.delegate = self;
51
52
  }
52
53
 
@@ -336,7 +337,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
336
337
  }
337
338
 
338
339
  - (NSString *)platformFlavorVersion {
339
- return @"5.0.0-beta.2";
340
+ return @"5.0.0-beta.3";
340
341
  }
341
342
 
342
343
  @end
@@ -38,15 +38,16 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
38
38
  appUserID:(nullable NSString *)appUserID
39
39
  observerMode:(BOOL)observerMode
40
40
  userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
41
- usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable) {
41
+ usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable
42
+ useAmazon:(BOOL)useAmazon) {
42
43
  RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey
43
- appUserID:appUserID
44
- observerMode:observerMode
45
- userDefaultsSuiteName:userDefaultsSuiteName
46
- platformFlavor:self.platformFlavor
47
- platformFlavorVersion:self.platformFlavorVersion
44
+ appUserID:appUserID
45
+ observerMode:observerMode
46
+ userDefaultsSuiteName:userDefaultsSuiteName
47
+ platformFlavor:self.platformFlavor
48
+ platformFlavorVersion:self.platformFlavorVersion
48
49
  usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
49
- dangerousSettings:nil];
50
+ dangerousSettings:nil];
50
51
  purchases.delegate = self;
51
52
  }
52
53
 
@@ -103,8 +104,8 @@ RCT_REMAP_METHOD(purchasePackage,
103
104
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
104
105
  }
105
106
 
106
- RCT_REMAP_METHOD(restoreTransactions,
107
- restoreTransactionsWithResolve:(RCTPromiseResolveBlock)resolve
107
+ RCT_REMAP_METHOD(restorePurchases,
108
+ restorePurchasesWithResolve:(RCTPromiseResolveBlock)resolve
108
109
  reject:(RCTPromiseRejectBlock)reject) {
109
110
  [RCCommonFunctionality restorePurchasesWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
110
111
  reject:reject]];
@@ -336,7 +337,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
336
337
  }
337
338
 
338
339
  - (NSString *)platformFlavorVersion {
339
- return @"5.0.0-beta.1";
340
+ return @"5.0.0-beta.2";
340
341
  }
341
342
 
342
343
  @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": "5.0.0-beta.2",
4
+ "version": "5.0.0-beta.3",
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",
@@ -2,7 +2,7 @@
2
2
  <!DOCTYPE html>
3
3
  <html>
4
4
  <head>
5
- <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.2/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.3/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>
@@ -2,7 +2,7 @@
2
2
  <!DOCTYPE html>
3
3
  <html>
4
4
  <head>
5
- <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.1/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.2/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>