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

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.
@@ -24,6 +24,6 @@ Pod::Spec.new do |spec|
24
24
  ]
25
25
 
26
26
  spec.dependency "React-Core"
27
- spec.dependency "PurchasesHybridCommon", '4.0.0'
27
+ spec.dependency "PurchasesHybridCommon", '4.1.1'
28
28
  spec.swift_version = '5.0'
29
29
  end
@@ -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.5'
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:4.0.0'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.1.1'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -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.5'
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:4.0.0'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.1.1'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -1,5 +1,5 @@
1
1
  android.useAndroidX=true
2
- Purchases_kotlinVersion=1.5.31
2
+ Purchases_kotlinVersion=1.6.21
3
3
  Purchases_compileSdkVersion=28
4
4
  Purchases_targetSdkVersion=28
5
5
  Purchases_minSdkVersion=16
@@ -53,6 +53,7 @@ internal object RNPurchasesConverters {
53
53
  return array
54
54
  }
55
55
 
56
+ @Suppress("UNCHECKED_CAST")
56
57
  private fun convertArrayToWritableArray(array: Array<Any?>): WritableArray {
57
58
  val writableArray: WritableArray = WritableNativeArray()
58
59
  for (item in array) {
@@ -71,6 +72,7 @@ internal object RNPurchasesConverters {
71
72
  }
72
73
 
73
74
  @JvmStatic
75
+ @Suppress("UNCHECKED_CAST")
74
76
  fun convertMapToWriteableMap(map: Map<String, *>): WritableMap {
75
77
  val writableMap: WritableMap = WritableNativeMap()
76
78
  for ((key, value) in map) {
@@ -87,4 +89,4 @@ internal object RNPurchasesConverters {
87
89
  }
88
90
  return writableMap
89
91
  }
90
- }
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,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,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
 
@@ -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
@@ -278,11 +290,17 @@ export default class Purchases {
278
290
  */
279
291
  static syncPurchases(): Promise<void>;
280
292
  /**
293
+ * @deprecated, use enableAdServicesAttributionTokenCollection instead.
281
294
  * Enable automatic collection of Apple Search Ad attribution. Disabled by default
282
295
  * @param {boolean} enabled Enable or not automatic apple search ads attribution collection
283
296
  * @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
284
297
  */
285
298
  static setAutomaticAppleSearchAdsAttributionCollection(enabled: boolean): Promise<void>;
299
+ /**
300
+ * Enable automatic collection of Apple Search Ad attribution on iOS. Disabled by default
301
+ * @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
302
+ */
303
+ static enableAdServicesAttributionTokenCollection(): Promise<void>;
286
304
  /**
287
305
  * @returns { Promise<boolean> } If the `appUserID` has been generated by RevenueCat or not.
288
306
  * @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
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
  });
@@ -495,6 +498,7 @@ var Purchases = /** @class */ (function () {
495
498
  });
496
499
  };
497
500
  /**
501
+ * @deprecated, use enableAdServicesAttributionTokenCollection instead.
498
502
  * Enable automatic collection of Apple Search Ad attribution. Disabled by default
499
503
  * @param {boolean} enabled Enable or not automatic apple search ads attribution collection
500
504
  * @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
@@ -509,6 +513,26 @@ var Purchases = /** @class */ (function () {
509
513
  });
510
514
  });
511
515
  };
516
+ /**
517
+ * Enable automatic collection of Apple Search Ad attribution on iOS. Disabled by default
518
+ * @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
519
+ */
520
+ Purchases.enableAdServicesAttributionTokenCollection = function () {
521
+ return __awaiter(this, void 0, void 0, function () {
522
+ return __generator(this, function (_a) {
523
+ switch (_a.label) {
524
+ case 0:
525
+ if (!(react_native_2.Platform.OS === "ios")) return [3 /*break*/, 2];
526
+ return [4 /*yield*/, Purchases.throwIfNotConfigured()];
527
+ case 1:
528
+ _a.sent();
529
+ RNPurchases.enableAdServicesAttributionTokenCollection();
530
+ _a.label = 2;
531
+ case 2: return [2 /*return*/];
532
+ }
533
+ });
534
+ });
535
+ };
512
536
  /**
513
537
  * @returns { Promise<boolean> } If the `appUserID` has been generated by RevenueCat or not.
514
538
  * @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
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
 
@@ -154,6 +155,15 @@ RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automati
154
155
  [RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:automaticAppleSearchAdsAttributionCollection];
155
156
  }
156
157
 
158
+ RCT_EXPORT_METHOD(enableAdServicesAttributionTokenCollection)
159
+ {
160
+ if (@available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *)) {
161
+ [RCCommonFunctionality enableAdServicesAttributionTokenCollection];
162
+ } else {
163
+ NSLog(@"[Purchases] Warning: tried to enable AdServices attribution token collection, but it's only available on iOS 14.3 or greater or macOS 11.1 or greater.");
164
+ }
165
+ }
166
+
157
167
  RCT_REMAP_METHOD(isAnonymous,
158
168
  isAnonymousWithResolve:(RCTPromiseResolveBlock)resolve
159
169
  reject:(RCTPromiseRejectBlock)reject) {
@@ -336,7 +346,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
336
346
  }
337
347
 
338
348
  - (NSString *)platformFlavorVersion {
339
- return @"5.0.0-beta.2";
349
+ return @"5.0.0-beta.5";
340
350
  }
341
351
 
342
352
  @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]];
@@ -154,6 +155,15 @@ RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automati
154
155
  [RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:automaticAppleSearchAdsAttributionCollection];
155
156
  }
156
157
 
158
+ RCT_EXPORT_METHOD(enableAdServicesAttributionTokenCollection)
159
+ {
160
+ if (@available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *)) {
161
+ [RCCommonFunctionality enableAdServicesAttributionTokenCollection];
162
+ } else {
163
+ NSLog(@"[Purchases] Warning: tried to enable AdServices attribution token collection, but it's only available on iOS 14.3 or greater or macOS 11.1 or greater.");
164
+ }
165
+ }
166
+
157
167
  RCT_REMAP_METHOD(isAnonymous,
158
168
  isAnonymousWithResolve:(RCTPromiseResolveBlock)resolve
159
169
  reject:(RCTPromiseRejectBlock)reject) {
@@ -336,7 +346,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
336
346
  }
337
347
 
338
348
  - (NSString *)platformFlavorVersion {
339
- return @"5.0.0-beta.1";
349
+ return @"5.0.0-beta.5";
340
350
  }
341
351
 
342
352
  @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.5",
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.5/" />
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.5/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>