react-native-purchases 5.10.0 → 5.11.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.
@@ -24,6 +24,6 @@ Pod::Spec.new do |spec|
24
24
  ]
25
25
 
26
26
  spec.dependency "React-Core"
27
- spec.dependency "PurchasesHybridCommon", '4.13.1'
27
+ spec.dependency "PurchasesHybridCommon", '4.13.4'
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.10.0'
32
+ versionName '5.11.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:4.13.1'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.13.4'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -28,6 +28,7 @@ internal object RNPurchasesConverters {
28
28
  key,
29
29
  convertReadableMapToJson(readableMap.getMap(key))
30
30
  )
31
+
31
32
  ReadableType.Array -> jsonObject.put(
32
33
  key,
33
34
  convertReadableArrayToJson(readableMap.getArray(key))
@@ -42,7 +43,7 @@ internal object RNPurchasesConverters {
42
43
  val array = JSONArray()
43
44
  for (i in 0 until readableArray!!.size()) {
44
45
  when (readableArray.getType(i)) {
45
- ReadableType.Null -> { }
46
+ ReadableType.Null -> {}
46
47
  ReadableType.Boolean -> array.put(readableArray.getBoolean(i))
47
48
  ReadableType.Number -> array.put(readableArray.getDouble(i))
48
49
  ReadableType.String -> array.put(readableArray.getString(i))
@@ -70,12 +70,12 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
70
70
 
71
71
  @ReactMethod
72
72
  public void addListener(String eventName) {
73
- // Keep: Required for RN built in Event Emitter Calls.
73
+ // Keep: Required for RN built in Event Emitter Calls.
74
74
  }
75
75
 
76
76
  @ReactMethod
77
77
  public void removeListeners(Integer count) {
78
- // Keep: Required for RN built in Event Emitter Calls.
78
+ // Keep: Required for RN built in Event Emitter Calls.
79
79
  }
80
80
 
81
81
  @ReactMethod
@@ -120,7 +120,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
120
120
  @Override
121
121
  public void onError(ErrorContainer errorContainer) {
122
122
  promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
123
- convertMapToWriteableMap(errorContainer.getInfo()));
123
+ convertMapToWriteableMap(errorContainer.getInfo()));
124
124
  }
125
125
  });
126
126
  }
@@ -132,12 +132,12 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
132
132
  @Nullable final String discountTimestamp,
133
133
  final Promise promise) {
134
134
  CommonKt.purchaseProduct(
135
- getCurrentActivity(),
136
- productIdentifier,
137
- upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
138
- upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
139
- type,
140
- getOnResult(promise));
135
+ getCurrentActivity(),
136
+ productIdentifier,
137
+ upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
138
+ upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
139
+ type,
140
+ getOnResult(promise));
141
141
  }
142
142
 
143
143
  @ReactMethod
@@ -147,12 +147,12 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
147
147
  @Nullable final String discountTimestamp,
148
148
  final Promise promise) {
149
149
  CommonKt.purchasePackage(
150
- getCurrentActivity(),
151
- packageIdentifier,
152
- offeringIdentifier,
153
- upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
154
- upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
155
- getOnResult(promise));
150
+ getCurrentActivity(),
151
+ packageIdentifier,
152
+ offeringIdentifier,
153
+ upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
154
+ upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
155
+ getOnResult(promise));
156
156
  }
157
157
 
158
158
  @ReactMethod
@@ -227,8 +227,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
227
227
  @Override
228
228
  public void onReceived(@NonNull CustomerInfo customerInfo) {
229
229
  reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
230
- .emit(RNPurchasesModule.CUSTOMER_INFO_UPDATED,
231
- convertMapToWriteableMap(CustomerInfoMapperKt.map(customerInfo)));
230
+ .emit(RNPurchasesModule.CUSTOMER_INFO_UPDATED,
231
+ convertMapToWriteableMap(CustomerInfoMapperKt.map(customerInfo)));
232
232
  }
233
233
 
234
234
  @ReactMethod
@@ -243,7 +243,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
243
243
 
244
244
  @ReactMethod
245
245
  public void isConfigured(Promise promise) {
246
- promise.resolve(Purchases.isConfigured());
246
+ promise.resolve(Purchases.isConfigured());
247
247
  }
248
248
 
249
249
  //================================================================================
@@ -258,74 +258,74 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
258
258
 
259
259
  @ReactMethod
260
260
  public void setEmail(String email) {
261
- SubscriberAttributesKt.setEmail(email);
261
+ SubscriberAttributesKt.setEmail(email);
262
262
  }
263
263
 
264
264
  @ReactMethod
265
265
  public void setPhoneNumber(String phoneNumber) {
266
- SubscriberAttributesKt.setPhoneNumber(phoneNumber);
266
+ SubscriberAttributesKt.setPhoneNumber(phoneNumber);
267
267
  }
268
268
 
269
269
  @ReactMethod
270
270
  public void setDisplayName(String displayName) {
271
- SubscriberAttributesKt.setDisplayName(displayName);
271
+ SubscriberAttributesKt.setDisplayName(displayName);
272
272
  }
273
273
 
274
274
  @ReactMethod
275
275
  public void setPushToken(String pushToken) {
276
- SubscriberAttributesKt.setPushToken(pushToken);
276
+ SubscriberAttributesKt.setPushToken(pushToken);
277
277
  }
278
278
 
279
279
  // region Attribution IDs
280
280
 
281
281
  @ReactMethod
282
282
  public void collectDeviceIdentifiers() {
283
- SubscriberAttributesKt.collectDeviceIdentifiers();
283
+ SubscriberAttributesKt.collectDeviceIdentifiers();
284
284
  }
285
285
 
286
286
  @ReactMethod
287
287
  public void setAdjustID(String adjustID) {
288
- SubscriberAttributesKt.setAdjustID(adjustID);
288
+ SubscriberAttributesKt.setAdjustID(adjustID);
289
289
  }
290
290
 
291
291
  @ReactMethod
292
292
  public void setAppsflyerID(String appsflyerID) {
293
- SubscriberAttributesKt.setAppsflyerID(appsflyerID);
293
+ SubscriberAttributesKt.setAppsflyerID(appsflyerID);
294
294
  }
295
295
 
296
296
  @ReactMethod
297
297
  public void setFBAnonymousID(String fbAnonymousID) {
298
- SubscriberAttributesKt.setFBAnonymousID(fbAnonymousID);
298
+ SubscriberAttributesKt.setFBAnonymousID(fbAnonymousID);
299
299
  }
300
300
 
301
301
  @ReactMethod
302
302
  public void setMparticleID(String mparticleID) {
303
- SubscriberAttributesKt.setMparticleID(mparticleID);
303
+ SubscriberAttributesKt.setMparticleID(mparticleID);
304
304
  }
305
305
 
306
306
  @ReactMethod
307
307
  public void setCleverTapID(String cleverTapID) {
308
- SubscriberAttributesKt.setCleverTapID(cleverTapID);
308
+ SubscriberAttributesKt.setCleverTapID(cleverTapID);
309
309
  }
310
310
 
311
311
  @ReactMethod
312
312
  public void setMixpanelDistinctID(String mixpanelDistinctID) {
313
- SubscriberAttributesKt.setMixpanelDistinctID(mixpanelDistinctID);
313
+ SubscriberAttributesKt.setMixpanelDistinctID(mixpanelDistinctID);
314
314
  }
315
315
 
316
316
  @ReactMethod
317
317
  public void setFirebaseAppInstanceID(String firebaseAppInstanceId) {
318
- SubscriberAttributesKt.setFirebaseAppInstanceID(firebaseAppInstanceId);
318
+ SubscriberAttributesKt.setFirebaseAppInstanceID(firebaseAppInstanceId);
319
319
  }
320
320
 
321
321
  @ReactMethod
322
322
  public void setOnesignalID(String onesignalID) {
323
- SubscriberAttributesKt.setOnesignalID(onesignalID);
323
+ SubscriberAttributesKt.setOnesignalID(onesignalID);
324
324
  }
325
325
 
326
326
  @ReactMethod
327
327
  public void setAirshipChannelID(String airshipChannelID) {
328
- SubscriberAttributesKt.setAirshipChannelID(airshipChannelID);
328
+ SubscriberAttributesKt.setAirshipChannelID(airshipChannelID);
329
329
  }
330
330
 
331
331
  // endregion
@@ -364,25 +364,34 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
364
364
 
365
365
  @ReactMethod
366
366
  public void canMakePayments(ReadableArray features, final Promise promise) {
367
- ArrayList<Integer> featureList = new ArrayList<>();
367
+ ArrayList<Integer> featureList = new ArrayList<>();
368
368
 
369
- if (features != null) {
370
- for (int i = 0; i < features.size(); i++) {
371
- featureList.add(features.getInt(i));
372
- }
373
- }
374
- CommonKt.canMakePayments(reactContext, featureList, new OnResultAny<Boolean>() {
375
- @Override
376
- public void onError(@Nullable ErrorContainer errorContainer) {
377
- promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
378
- convertMapToWriteableMap(errorContainer.getInfo()));
369
+ if (features != null) {
370
+ for (int i = 0; i < features.size(); i++) {
371
+ featureList.add(features.getInt(i));
372
+ }
379
373
  }
374
+ CommonKt.canMakePayments(reactContext, featureList, new OnResultAny<Boolean>() {
375
+ @Override
376
+ public void onError(@Nullable ErrorContainer errorContainer) {
377
+ promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
378
+ convertMapToWriteableMap(errorContainer.getInfo()));
379
+ }
380
380
 
381
- @Override
382
- public void onReceived(Boolean result) {
383
- promise.resolve(result);
384
- }
385
- });
381
+ @Override
382
+ public void onReceived(Boolean result) {
383
+ promise.resolve(result);
384
+ }
385
+ });
386
+ }
387
+
388
+ @ReactMethod
389
+ public void syncObserverModeAmazonPurchase(String productID, String receiptID,
390
+ String amazonUserID, String isoCurrencyCode,
391
+ Double price, final Promise promise) {
392
+ Purchases.getSharedInstance().syncObserverModeAmazonPurchase(productID, receiptID,
393
+ amazonUserID, isoCurrencyCode, price);
394
+ promise.resolve(null);
386
395
  }
387
396
 
388
397
  // endregion
@@ -402,7 +411,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
402
411
  @Override
403
412
  public void onError(ErrorContainer errorContainer) {
404
413
  promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
405
- convertMapToWriteableMap(errorContainer.getInfo()));
414
+ convertMapToWriteableMap(errorContainer.getInfo()));
406
415
  }
407
416
  };
408
417
  }
@@ -15,20 +15,20 @@ import com.facebook.react.bridge.JavaScriptModule;
15
15
 
16
16
 
17
17
  public class RNPurchasesPackage implements ReactPackage {
18
- @NonNull
19
- @Override
20
- public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
21
- return Arrays.<NativeModule>asList(new RNPurchasesModule(reactContext));
22
- }
23
-
24
- // Deprecated from RN 0.47
25
- public List<Class<? extends JavaScriptModule>> createJSModules() {
26
- return Collections.emptyList();
27
- }
28
-
29
- @NonNull
30
- @Override
31
- public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
32
- return Collections.emptyList();
33
- }
34
- }
18
+ @NonNull
19
+ @Override
20
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
21
+ return Arrays.<NativeModule>asList(new RNPurchasesModule(reactContext));
22
+ }
23
+
24
+ // Deprecated from RN 0.47
25
+ public List<Class<? extends JavaScriptModule>> createJSModules() {
26
+ return Collections.emptyList();
27
+ }
28
+
29
+ @NonNull
30
+ @Override
31
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
32
+ return Collections.emptyList();
33
+ }
34
+ }
@@ -131,13 +131,13 @@ export default class Purchases {
131
131
  * Currently, these are only relevant for Google Play Android users:
132
132
  * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType
133
133
  * @readonly
134
- * @enum {string}
134
+ * @enum {string}
135
135
  */
136
136
  static BILLING_FEATURE: typeof BILLING_FEATURE;
137
137
  /**
138
138
  * Enum with possible return states for beginning refund request.
139
139
  * @readonly
140
- * @enum {string}
140
+ * @enum {string}
141
141
  */
142
142
  static REFUND_REQUEST_STATUS: typeof REFUND_REQUEST_STATUS;
143
143
  /**
@@ -366,6 +366,21 @@ export default class Purchases {
366
366
  * syncing purchases.
367
367
  */
368
368
  static syncPurchases(): Promise<void>;
369
+ /**
370
+ * This method will send a purchase to the RevenueCat backend. This function should only be called if you are
371
+ * in Amazon observer mode or performing a client side migration of your current users to RevenueCat.
372
+ *
373
+ * The receipt IDs are cached if successfully posted so they are not posted more than once.
374
+ *
375
+ * @param {string} productID Product ID associated to the purchase.
376
+ * @param {string} receiptID ReceiptId that represents the Amazon purchase.
377
+ * @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase.
378
+ * @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format.
379
+ * @param {(number|null|undefined)} price Product's price.
380
+ * @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
381
+ * syncing purchases.
382
+ */
383
+ static syncObserverModeAmazonPurchase(productID: string, receiptID: string, amazonUserID: string, isoCurrencyCode?: string | null, price?: number | null): Promise<void>;
369
384
  /**
370
385
  * @deprecated, use enableAdServicesAttributionTokenCollection instead.
371
386
  * Enable automatic collection of Apple Search Ad attribution. Disabled by default
@@ -681,5 +696,6 @@ export default class Purchases {
681
696
  static isConfigured(): Promise<boolean>;
682
697
  private static throwIfNotConfigured;
683
698
  private static throwIfAndroidPlatform;
699
+ private static throwIfIOSPlatform;
684
700
  private static convertIntToRefundRequestStatus;
685
701
  }
package/dist/purchases.js CHANGED
@@ -551,6 +551,36 @@ var Purchases = /** @class */ (function () {
551
551
  });
552
552
  });
553
553
  };
554
+ /**
555
+ * This method will send a purchase to the RevenueCat backend. This function should only be called if you are
556
+ * in Amazon observer mode or performing a client side migration of your current users to RevenueCat.
557
+ *
558
+ * The receipt IDs are cached if successfully posted so they are not posted more than once.
559
+ *
560
+ * @param {string} productID Product ID associated to the purchase.
561
+ * @param {string} receiptID ReceiptId that represents the Amazon purchase.
562
+ * @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase.
563
+ * @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format.
564
+ * @param {(number|null|undefined)} price Product's price.
565
+ * @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
566
+ * syncing purchases.
567
+ */
568
+ Purchases.syncObserverModeAmazonPurchase = function (productID, receiptID, amazonUserID, isoCurrencyCode, price) {
569
+ return __awaiter(this, void 0, void 0, function () {
570
+ return __generator(this, function (_a) {
571
+ switch (_a.label) {
572
+ case 0: return [4 /*yield*/, Purchases.throwIfIOSPlatform()];
573
+ case 1:
574
+ _a.sent();
575
+ return [4 /*yield*/, Purchases.throwIfNotConfigured()];
576
+ case 2:
577
+ _a.sent();
578
+ RNPurchases.syncObserverModeAmazonPurchase(productID, receiptID, amazonUserID, isoCurrencyCode, price);
579
+ return [2 /*return*/];
580
+ }
581
+ });
582
+ });
583
+ };
554
584
  /**
555
585
  * @deprecated, use enableAdServicesAttributionTokenCollection instead.
556
586
  * Enable automatic collection of Apple Search Ad attribution. Disabled by default
@@ -1308,6 +1338,16 @@ var Purchases = /** @class */ (function () {
1308
1338
  });
1309
1339
  });
1310
1340
  };
1341
+ Purchases.throwIfIOSPlatform = function () {
1342
+ return __awaiter(this, void 0, void 0, function () {
1343
+ return __generator(this, function (_a) {
1344
+ if (react_native_2.Platform.OS === "ios") {
1345
+ throw new errors_1.UnsupportedPlatformError();
1346
+ }
1347
+ return [2 /*return*/];
1348
+ });
1349
+ });
1350
+ };
1311
1351
  Purchases.convertIntToRefundRequestStatus = function (refundRequestStatusInt) {
1312
1352
  switch (refundRequestStatusInt) {
1313
1353
  case 0:
@@ -1329,13 +1369,13 @@ var Purchases = /** @class */ (function () {
1329
1369
  * Currently, these are only relevant for Google Play Android users:
1330
1370
  * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType
1331
1371
  * @readonly
1332
- * @enum {string}
1372
+ * @enum {string}
1333
1373
  */
1334
1374
  Purchases.BILLING_FEATURE = BILLING_FEATURE;
1335
1375
  /**
1336
1376
  * Enum with possible return states for beginning refund request.
1337
1377
  * @readonly
1338
- * @enum {string}
1378
+ * @enum {string}
1339
1379
  */
1340
1380
  Purchases.REFUND_REQUEST_STATUS = REFUND_REQUEST_STATUS;
1341
1381
  /**
package/ios/RNPurchases.m CHANGED
@@ -439,7 +439,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
439
439
  }
440
440
 
441
441
  - (NSString *)platformFlavorVersion {
442
- return @"5.10.0";
442
+ return @"5.11.0";
443
443
  }
444
444
 
445
445
  @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.10.0",
4
+ "version": "5.11.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",
@@ -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.10.0/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.11.0/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>
@@ -743,6 +743,7 @@ NativeModules.RNPurchases = {
743
743
  logIn: jest.fn(),
744
744
  logOut: jest.fn(),
745
745
  syncPurchases: jest.fn(),
746
+ syncObserverModeAmazonPurchase: jest.fn(),
746
747
  setFinishTransactions: jest.fn(),
747
748
  purchaseProduct: jest.fn(),
748
749
  purchasePackage: jest.fn(),