react-native-purchases 4.1.4 → 4.3.2

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.
@@ -23,6 +23,6 @@ Pod::Spec.new do |spec|
23
23
  ]
24
24
 
25
25
  spec.dependency "React-Core"
26
- spec.dependency "PurchasesHybridCommon", '1.7.1'
26
+ spec.dependency "PurchasesHybridCommon", '1.9.1'
27
27
  spec.swift_version = '5.0'
28
28
  end
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <classpath>
3
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
4
+ <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5
+ <classpathentry kind="output" path="bin/default"/>
6
+ </classpath>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>android</name>
4
+ <comment>Project ReactNativeSample-react-native-purchases created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>org.eclipse.jdt.core.javanature</nature>
21
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
+ </natures>
23
+ <filteredResources>
24
+ <filter>
25
+ <id>1634928680138</id>
26
+ <name></name>
27
+ <type>30</type>
28
+ <matcher>
29
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
+ <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
+ </matcher>
32
+ </filter>
33
+ </filteredResources>
34
+ </projectDescription>
@@ -0,0 +1,13 @@
1
+ arguments=
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5
+ connection.project.dir=
6
+ eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=/Users/cesardelavega/.sdkman/candidates/java/current
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '4.1.4'
32
+ versionName '4.3.2'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -122,6 +122,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
122
122
  dependencies {
123
123
  //noinspection GradleDynamicVersion
124
124
  api 'com.facebook.react:react-native:+'
125
- implementation 'com.revenuecat.purchases:purchases-hybrid-common:1.7.1'
125
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:1.9.1'
126
126
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
127
127
  }
@@ -16,14 +16,16 @@ import com.facebook.react.bridge.WritableArray;
16
16
  import com.facebook.react.modules.core.DeviceEventManagerModule;
17
17
  import com.revenuecat.purchases.PurchaserInfo;
18
18
  import com.revenuecat.purchases.Purchases;
19
+ import com.revenuecat.purchases.common.PlatformInfo;
19
20
  import com.revenuecat.purchases.hybridcommon.CommonKt;
20
21
  import com.revenuecat.purchases.hybridcommon.ErrorContainer;
21
22
  import com.revenuecat.purchases.hybridcommon.OnResult;
23
+ import com.revenuecat.purchases.hybridcommon.OnResultAny;
22
24
  import com.revenuecat.purchases.hybridcommon.OnResultList;
23
- import com.revenuecat.purchases.common.PlatformInfo;
24
25
  import com.revenuecat.purchases.hybridcommon.SubscriberAttributesKt;
25
26
  import com.revenuecat.purchases.hybridcommon.mappers.PurchaserInfoMapperKt;
26
27
  import com.revenuecat.purchases.interfaces.UpdatedPurchaserInfoListener;
28
+ import com.revenuecat.purchases.interfaces.Callback;
27
29
 
28
30
  import org.jetbrains.annotations.NotNull;
29
31
  import org.json.JSONException;
@@ -41,7 +43,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
41
43
 
42
44
  private static final String PURCHASER_INFO_UPDATED = "Purchases-PurchaserInfoUpdated";
43
45
  public static final String PLATFORM_NAME = "react-native";
44
- public static final String PLUGIN_VERSION = "4.0.0";
46
+ public static final String PLUGIN_VERSION = "4.3.2";
45
47
 
46
48
  private final ReactApplicationContext reactContext;
47
49
 
@@ -156,6 +158,16 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
156
158
  CommonKt.restoreTransactions(getOnResult(promise));
157
159
  }
158
160
 
161
+ @ReactMethod
162
+ public void logOut(final Promise promise) {
163
+ CommonKt.logOut(getOnResult(promise));
164
+ }
165
+
166
+ @ReactMethod
167
+ public void logIn(String appUserID, final Promise promise) {
168
+ CommonKt.logIn(appUserID, getOnResult(promise));
169
+ }
170
+
159
171
  @ReactMethod
160
172
  public void reset(final Promise promise) {
161
173
  CommonKt.reset(getOnResult(promise));
@@ -318,6 +330,29 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
318
330
  SubscriberAttributesKt.setCreative(creative);
319
331
  }
320
332
 
333
+ @ReactMethod
334
+ public void canMakePayments(ReadableArray features, final Promise promise) {
335
+ ArrayList<Integer> featureList = new ArrayList<>();
336
+
337
+ if (features != null) {
338
+ for (int i = 0; i < features.size(); i++) {
339
+ featureList.add(features.getInt(i));
340
+ }
341
+ }
342
+ CommonKt.canMakePayments(reactContext, featureList, new OnResultAny<Boolean>() {
343
+ @Override
344
+ public void onError(@Nullable ErrorContainer errorContainer) {
345
+ promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
346
+ convertMapToWriteableMap(errorContainer.getInfo()));
347
+ }
348
+
349
+ @Override
350
+ public void onReceived(Boolean result) {
351
+ promise.resolve(result);
352
+ }
353
+ });
354
+ }
355
+
321
356
  // endregion
322
357
 
323
358
  //================================================================================
package/dist/errors.d.ts CHANGED
@@ -27,6 +27,10 @@ export interface PurchasesError {
27
27
  code: PURCHASES_ERROR_CODE;
28
28
  message: string;
29
29
  readableErrorCode: string;
30
+ userInfo: ErrorInfo;
30
31
  underlyingErrorMessage: string;
31
32
  userCancelled: boolean | null;
32
33
  }
34
+ export interface ErrorInfo {
35
+ readableErrorCode: string;
36
+ }
@@ -33,10 +33,9 @@ export interface PurchasesEntitlementInfo {
33
33
  */
34
34
  readonly expirationDate: string | null;
35
35
  /**
36
- * The store where this entitlement was unlocked from. Either: appStore, macAppStore, playStore, stripe,
37
- * promotional, unknownStore
36
+ * The store where this entitlement was unlocked from.
38
37
  */
39
- readonly store: string;
38
+ readonly store: "PLAY_STORE" | "APP_STORE" | "STRIPE" | "MAC_APP_STORE" | "PROMOTIONAL" | "AMAZON" | "UNKNOWN_STORE";
40
39
  /**
41
40
  * The product identifier that unlocked this entitlement
42
41
  */
@@ -30,6 +30,46 @@ export declare enum PURCHASE_TYPE {
30
30
  */
31
31
  SUBS = "subs"
32
32
  }
33
+ /**
34
+ * Enum for billing features.
35
+ * Currently, these are only relevant for Google Play Android users:
36
+ * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType
37
+ */
38
+ export declare enum BILLING_FEATURE {
39
+ /**
40
+ * Purchase/query for subscriptions.
41
+ */
42
+ SUBSCRIPTIONS = 0,
43
+ /**
44
+ * Subscriptions update/replace.
45
+ */
46
+ SUBSCRIPTIONS_UPDATE = 1,
47
+ /**
48
+ * Purchase/query for in-app items on VR.
49
+ */
50
+ IN_APP_ITEMS_ON_VR = 2,
51
+ /**
52
+ * Purchase/query for subscriptions on VR.
53
+ */
54
+ SUBSCRIPTIONS_ON_VR = 3,
55
+ /**
56
+ * Launch a price change confirmation flow.
57
+ */
58
+ PRICE_CHANGE_CONFIRMATION = 4
59
+ }
60
+ /**
61
+ * Holds the logIn result
62
+ */
63
+ export interface LogInResult {
64
+ /**
65
+ * The Purchaser Info for the user.
66
+ */
67
+ readonly purchaserInfo: PurchaserInfo;
68
+ /**
69
+ * True if the call resulted in a new user getting created in the RevenueCat backend.
70
+ */
71
+ readonly created: boolean;
72
+ }
33
73
  export default class Purchases {
34
74
  /**
35
75
  * Enum for attribution networks
@@ -51,6 +91,14 @@ export default class Purchases {
51
91
  * @enum {string}
52
92
  */
53
93
  static PURCHASE_TYPE: typeof PURCHASE_TYPE;
94
+ /**
95
+ * Enum for billing features.
96
+ * Currently, these are only relevant for Google Play Android users:
97
+ * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType
98
+ * @readonly
99
+ * @enum {string}
100
+ */
101
+ static BILLING_FEATURE: typeof BILLING_FEATURE;
54
102
  /**
55
103
  * Replace SKU's ProrationMode.
56
104
  * @readonly
@@ -86,9 +134,10 @@ export default class Purchases {
86
134
  */
87
135
  static setup(apiKey: string, appUserID?: string | null, observerMode?: boolean, userDefaultsSuiteName?: string): void;
88
136
  /**
89
- * @param {boolean} allowSharing Set this to true if you are passing in an appUserID but it is anonymous, this is true by default if you didn't pass an appUserID
137
+ * @deprecated, configure behavior through the RevenueCat dashboard instead.
90
138
  * If an user tries to purchase a product that is active on the current app store account, we will treat it as a restore and alias
91
139
  * the new ID with the previous id.
140
+ * @param {boolean} allowSharing Set this to true if you are passing in an appUserID but it is anonymous, this is true by default if you didn't pass an appUserID
92
141
  */
93
142
  static setAllowSharingStoreAccount(allowSharing: boolean): void;
94
143
  /**
@@ -206,18 +255,34 @@ export default class Purchases {
206
255
  */
207
256
  static getAppUserID(): string;
208
257
  /**
258
+ * This function will logIn the current user with an appUserID. Typically this would be used after a log in
259
+ * to identify a user without calling configure.
260
+ * @param {String} appUserID The appUserID that should be linked to the currently user
261
+ * @returns {Promise<LogInResult>} A promise of an object that contains the purchaserInfo after logging in, as well as a boolean indicating
262
+ * whether the user has just been created for the first time in the RevenueCat backend.
263
+ */
264
+ static logIn(appUserID: string): Promise<LogInResult>;
265
+ /**
266
+ * Logs out the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.
267
+ * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
268
+ */
269
+ static logOut(): Promise<PurchaserInfo>;
270
+ /**
271
+ * @deprecated, use logIn instead.
209
272
  * This function will alias two appUserIDs together.
210
273
  * @param {String} newAppUserID The new appUserID that should be linked to the currently identified appUserID. Needs to be a string.
211
274
  * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
212
275
  */
213
276
  static createAlias(newAppUserID: string): Promise<PurchaserInfo>;
214
277
  /**
278
+ * @deprecated, use logIn instead.
215
279
  * This function will identify the current user with an appUserID. Typically this would be used after a logout to identify a new user without calling configure
216
280
  * @param {String} newAppUserID The appUserID that should be linked to the currently user
217
281
  * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
218
282
  */
219
283
  static identify(newAppUserID: string): Promise<PurchaserInfo>;
220
284
  /**
285
+ * @deprecated, use logOut instead.
221
286
  * Resets the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.
222
287
  * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
223
288
  */
@@ -245,9 +310,9 @@ export default class Purchases {
245
310
  */
246
311
  static setAutomaticAppleSearchAdsAttributionCollection(enabled: boolean): void;
247
312
  /**
248
- * @returns { boolean } If the `appUserID` has been generated by RevenueCat or not.
313
+ * @returns { Promise<boolean> } If the `appUserID` has been generated by RevenueCat or not.
249
314
  */
250
- static isAnonymous(): boolean;
315
+ static isAnonymous(): Promise<boolean>;
251
316
  /**
252
317
  * iOS only. Computes whether or not a user is eligible for the introductory pricing period of a given product.
253
318
  * You should use this method to determine whether or not you show the user the normal product price or the
@@ -406,5 +471,16 @@ export default class Purchases {
406
471
  * @param creative Empty String or null will delete the subscriber attribute.
407
472
  */
408
473
  static setCreative(creative: string | null): void;
474
+ /**
475
+ * Check if billing is supported for the current user (meaning IN-APP purchases are supported)
476
+ * and optionally, whether a list of specified feature types are supported.
477
+ *
478
+ * Note: Billing features are only relevant to Google Play Android users.
479
+ * For other stores and platforms, billing features won't be checked.
480
+ * @param feature An array of feature types to check for support. Feature types must be one of
481
+ * [BILLING_FEATURE]. By default, is an empty list and no specific feature support will be checked.
482
+ * @returns {Promise<Boolean>} promise with boolean response
483
+ */
484
+ static canMakePayments(features?: BILLING_FEATURE[]): Promise<boolean>;
409
485
  }
410
486
  export {};
package/dist/purchases.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PURCHASE_TYPE = exports.ATTRIBUTION_NETWORK = void 0;
3
+ exports.BILLING_FEATURE = exports.PURCHASE_TYPE = exports.ATTRIBUTION_NETWORK = void 0;
4
4
  var react_native_1 = require("react-native");
5
5
  var errors_1 = require("./errors");
6
6
  var offerings_1 = require("./offerings");
@@ -38,6 +38,34 @@ var PURCHASE_TYPE;
38
38
  */
39
39
  PURCHASE_TYPE["SUBS"] = "subs";
40
40
  })(PURCHASE_TYPE = exports.PURCHASE_TYPE || (exports.PURCHASE_TYPE = {}));
41
+ /**
42
+ * Enum for billing features.
43
+ * Currently, these are only relevant for Google Play Android users:
44
+ * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType
45
+ */
46
+ var BILLING_FEATURE;
47
+ (function (BILLING_FEATURE) {
48
+ /**
49
+ * Purchase/query for subscriptions.
50
+ */
51
+ BILLING_FEATURE[BILLING_FEATURE["SUBSCRIPTIONS"] = 0] = "SUBSCRIPTIONS";
52
+ /**
53
+ * Subscriptions update/replace.
54
+ */
55
+ BILLING_FEATURE[BILLING_FEATURE["SUBSCRIPTIONS_UPDATE"] = 1] = "SUBSCRIPTIONS_UPDATE";
56
+ /**
57
+ * Purchase/query for in-app items on VR.
58
+ */
59
+ BILLING_FEATURE[BILLING_FEATURE["IN_APP_ITEMS_ON_VR"] = 2] = "IN_APP_ITEMS_ON_VR";
60
+ /**
61
+ * Purchase/query for subscriptions on VR.
62
+ */
63
+ BILLING_FEATURE[BILLING_FEATURE["SUBSCRIPTIONS_ON_VR"] = 3] = "SUBSCRIPTIONS_ON_VR";
64
+ /**
65
+ * Launch a price change confirmation flow.
66
+ */
67
+ BILLING_FEATURE[BILLING_FEATURE["PRICE_CHANGE_CONFIRMATION"] = 4] = "PRICE_CHANGE_CONFIRMATION";
68
+ })(BILLING_FEATURE = exports.BILLING_FEATURE || (exports.BILLING_FEATURE = {}));
41
69
  var Purchases = /** @class */ (function () {
42
70
  function Purchases() {
43
71
  }
@@ -58,9 +86,10 @@ var Purchases = /** @class */ (function () {
58
86
  RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName);
59
87
  };
60
88
  /**
61
- * @param {boolean} allowSharing Set this to true if you are passing in an appUserID but it is anonymous, this is true by default if you didn't pass an appUserID
89
+ * @deprecated, configure behavior through the RevenueCat dashboard instead.
62
90
  * If an user tries to purchase a product that is active on the current app store account, we will treat it as a restore and alias
63
91
  * the new ID with the previous id.
92
+ * @param {boolean} allowSharing Set this to true if you are passing in an appUserID but it is anonymous, this is true by default if you didn't pass an appUserID
64
93
  */
65
94
  Purchases.setAllowSharingStoreAccount = function (allowSharing) {
66
95
  RNPurchases.setAllowSharingStoreAccount(allowSharing);
@@ -244,6 +273,28 @@ var Purchases = /** @class */ (function () {
244
273
  return RNPurchases.getAppUserID();
245
274
  };
246
275
  /**
276
+ * This function will logIn the current user with an appUserID. Typically this would be used after a log in
277
+ * to identify a user without calling configure.
278
+ * @param {String} appUserID The appUserID that should be linked to the currently user
279
+ * @returns {Promise<LogInResult>} A promise of an object that contains the purchaserInfo after logging in, as well as a boolean indicating
280
+ * whether the user has just been created for the first time in the RevenueCat backend.
281
+ */
282
+ Purchases.logIn = function (appUserID) {
283
+ // noinspection SuspiciousTypeOfGuard
284
+ if (typeof appUserID !== "string") {
285
+ throw new Error("appUserID needs to be a string");
286
+ }
287
+ return RNPurchases.logIn(appUserID);
288
+ };
289
+ /**
290
+ * Logs out the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.
291
+ * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
292
+ */
293
+ Purchases.logOut = function () {
294
+ return RNPurchases.logOut();
295
+ };
296
+ /**
297
+ * @deprecated, use logIn instead.
247
298
  * This function will alias two appUserIDs together.
248
299
  * @param {String} newAppUserID The new appUserID that should be linked to the currently identified appUserID. Needs to be a string.
249
300
  * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
@@ -256,6 +307,7 @@ var Purchases = /** @class */ (function () {
256
307
  return RNPurchases.createAlias(newAppUserID);
257
308
  };
258
309
  /**
310
+ * @deprecated, use logIn instead.
259
311
  * This function will identify the current user with an appUserID. Typically this would be used after a logout to identify a new user without calling configure
260
312
  * @param {String} newAppUserID The appUserID that should be linked to the currently user
261
313
  * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
@@ -268,6 +320,7 @@ var Purchases = /** @class */ (function () {
268
320
  return RNPurchases.identify(newAppUserID);
269
321
  };
270
322
  /**
323
+ * @deprecated, use logOut instead.
271
324
  * Resets the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.
272
325
  * @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
273
326
  */
@@ -307,7 +360,7 @@ var Purchases = /** @class */ (function () {
307
360
  }
308
361
  };
309
362
  /**
310
- * @returns { boolean } If the `appUserID` has been generated by RevenueCat or not.
363
+ * @returns { Promise<boolean> } If the `appUserID` has been generated by RevenueCat or not.
311
364
  */
312
365
  Purchases.isAnonymous = function () {
313
366
  return RNPurchases.isAnonymous();
@@ -518,6 +571,20 @@ var Purchases = /** @class */ (function () {
518
571
  Purchases.setCreative = function (creative) {
519
572
  RNPurchases.setCreative(creative);
520
573
  };
574
+ /**
575
+ * Check if billing is supported for the current user (meaning IN-APP purchases are supported)
576
+ * and optionally, whether a list of specified feature types are supported.
577
+ *
578
+ * Note: Billing features are only relevant to Google Play Android users.
579
+ * For other stores and platforms, billing features won't be checked.
580
+ * @param feature An array of feature types to check for support. Feature types must be one of
581
+ * [BILLING_FEATURE]. By default, is an empty list and no specific feature support will be checked.
582
+ * @returns {Promise<Boolean>} promise with boolean response
583
+ */
584
+ Purchases.canMakePayments = function (features) {
585
+ if (features === void 0) { features = []; }
586
+ return RNPurchases.canMakePayments(features);
587
+ };
521
588
  /**
522
589
  * Enum for attribution networks
523
590
  * @readonly
@@ -538,6 +605,14 @@ var Purchases = /** @class */ (function () {
538
605
  * @enum {string}
539
606
  */
540
607
  Purchases.PURCHASE_TYPE = PURCHASE_TYPE;
608
+ /**
609
+ * Enum for billing features.
610
+ * Currently, these are only relevant for Google Play Android users:
611
+ * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType
612
+ * @readonly
613
+ * @enum {string}
614
+ */
615
+ Purchases.BILLING_FEATURE = BILLING_FEATURE;
541
616
  /**
542
617
  * Replace SKU's ProrationMode.
543
618
  * @readonly
package/ios/RNPurchases.m CHANGED
@@ -11,22 +11,22 @@
11
11
 
12
12
  @interface RNPurchases () <RCPurchasesDelegate>
13
13
 
14
- @property(nonatomic, retain) NSMutableArray<RCDeferredPromotionalPurchaseBlock> *defermentBlocks;
14
+ @property (nonatomic, retain) NSMutableArray<RCDeferredPromotionalPurchaseBlock> *defermentBlocks;
15
15
 
16
16
  @end
17
17
 
18
+
18
19
  NSString *RNPurchasesPurchaserInfoUpdatedEvent = @"Purchases-PurchaserInfoUpdated";
19
20
  NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchasePromoProduct";
20
21
 
22
+
21
23
  @implementation RNPurchases
22
24
 
23
- - (dispatch_queue_t)methodQueue
24
- {
25
+ - (dispatch_queue_t)methodQueue {
25
26
  return dispatch_get_main_queue();
26
27
  }
27
28
 
28
- - (NSArray<NSString *> *)supportedEvents
29
- {
29
+ - (NSArray<NSString *> *)supportedEvents {
30
30
  return @[RNPurchasesPurchaserInfoUpdatedEvent, RNPurchasesShouldPurchasePromoProductEvent];
31
31
  }
32
32
 
@@ -35,8 +35,7 @@ RCT_EXPORT_MODULE();
35
35
  RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
36
36
  appUserID:(nullable NSString *)appUserID
37
37
  observerMode:(BOOL)observerMode
38
- userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName)
39
- {
38
+ userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName) {
40
39
  [RCPurchases configureWithAPIKey:apiKey
41
40
  appUserID:appUserID
42
41
  observerMode:observerMode
@@ -47,20 +46,20 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
47
46
  [RCCommonFunctionality configure];
48
47
  }
49
48
 
50
- RCT_EXPORT_METHOD(setAllowSharingStoreAccount:(BOOL)allowSharingStoreAccount)
51
- {
49
+ RCT_EXPORT_METHOD(setAllowSharingStoreAccount:(BOOL)allowSharingStoreAccount) {
50
+ #pragma GCC diagnostic push
51
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
52
52
  [RCCommonFunctionality setAllowSharingStoreAccount:allowSharingStoreAccount];
53
+ #pragma GCC diagnostic pop
53
54
  }
54
55
 
55
- RCT_EXPORT_METHOD(setFinishTransactions:(BOOL)finishTransactions)
56
- {
56
+ RCT_EXPORT_METHOD(setFinishTransactions:(BOOL)finishTransactions) {
57
57
  [RCCommonFunctionality setFinishTransactions:finishTransactions];
58
58
  }
59
59
 
60
60
  RCT_EXPORT_METHOD(addAttributionData:(NSDictionary *)data
61
61
  forNetwork:(NSInteger)network
62
- forNetworkUserId:(nullable NSString *)networkUserId)
63
- {
62
+ forNetworkUserId:(nullable NSString *)networkUserId) {
64
63
  #pragma GCC diagnostic push
65
64
  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
66
65
  [RCCommonFunctionality addAttributionData:data network:network networkUserId:networkUserId];
@@ -69,16 +68,15 @@ RCT_EXPORT_METHOD(addAttributionData:(NSDictionary *)data
69
68
 
70
69
  RCT_REMAP_METHOD(getOfferings,
71
70
  getOfferingsWithResolve:(RCTPromiseResolveBlock)resolve
72
- reject:(RCTPromiseRejectBlock)reject)
73
- {
74
- [RCCommonFunctionality getOfferingsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
71
+ reject:(RCTPromiseRejectBlock)reject) {
72
+ [RCCommonFunctionality getOfferingsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
73
+ reject:reject]];
75
74
  }
76
75
 
77
76
  RCT_EXPORT_METHOD(getProductInfo:(NSArray *)products
78
77
  type:(NSString *)type
79
78
  resolve:(RCTPromiseResolveBlock)resolve
80
- reject:(RCTPromiseRejectBlock)reject)
81
- {
79
+ reject:(RCTPromiseRejectBlock)reject) {
82
80
  [RCCommonFunctionality getProductInfo:products completionBlock:^(NSArray<NSDictionary *> *productObjects) {
83
81
  resolve(productObjects);
84
82
  }];
@@ -90,8 +88,7 @@ RCT_REMAP_METHOD(purchaseProduct,
90
88
  type:(NSString *)type
91
89
  signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
92
90
  resolve:(RCTPromiseResolveBlock)resolve
93
- reject:(RCTPromiseRejectBlock)reject)
94
- {
91
+ reject:(RCTPromiseRejectBlock)reject) {
95
92
  [RCCommonFunctionality purchaseProduct:productIdentifier
96
93
  signedDiscountTimestamp:signedDiscountTimestamp
97
94
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
@@ -104,8 +101,7 @@ RCT_REMAP_METHOD(purchasePackage,
104
101
  upgradeInfo:(NSDictionary *)upgradeInfo
105
102
  signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
106
103
  resolve:(RCTPromiseResolveBlock)resolve
107
- reject:(RCTPromiseRejectBlock)reject)
108
- {
104
+ reject:(RCTPromiseRejectBlock)reject) {
109
105
  [RCCommonFunctionality purchasePackage:packageIdentifier
110
106
  offering:offeringIdentifier
111
107
  signedDiscountTimestamp:signedDiscountTimestamp
@@ -115,7 +111,8 @@ RCT_REMAP_METHOD(purchasePackage,
115
111
  RCT_REMAP_METHOD(restoreTransactions,
116
112
  restoreTransactionsWithResolve:(RCTPromiseResolveBlock)resolve
117
113
  reject:(RCTPromiseRejectBlock)reject) {
118
- [RCCommonFunctionality restoreTransactionsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
114
+ [RCCommonFunctionality restoreTransactionsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
115
+ reject:reject]];
119
116
  }
120
117
 
121
118
  RCT_EXPORT_METHOD(syncPurchases) {
@@ -124,30 +121,47 @@ RCT_EXPORT_METHOD(syncPurchases) {
124
121
 
125
122
  RCT_REMAP_METHOD(getAppUserID,
126
123
  getAppUserIDWithResolve:(RCTPromiseResolveBlock)resolve
127
- reject:(RCTPromiseRejectBlock)reject)
128
- {
124
+ reject:(RCTPromiseRejectBlock)reject) {
129
125
  resolve([RCCommonFunctionality appUserID]);
130
126
  }
131
127
 
132
128
  RCT_EXPORT_METHOD(createAlias:(nullable NSString *)newAppUserID
133
129
  resolve:(RCTPromiseResolveBlock)resolve
134
- reject:(RCTPromiseRejectBlock)reject)
135
- {
130
+ reject:(RCTPromiseRejectBlock)reject) {
136
131
  [RCCommonFunctionality createAlias:newAppUserID
137
132
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
138
133
  }
139
134
 
135
+ RCT_EXPORT_METHOD(logIn:(nonnull NSString *)appUserID
136
+ resolve:(RCTPromiseResolveBlock)resolve
137
+ reject:(RCTPromiseRejectBlock)reject) {
138
+ [RCCommonFunctionality logInWithAppUserID:appUserID
139
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
140
+ }
141
+
142
+ RCT_REMAP_METHOD(logOut,
143
+ logOutWithResolve:(RCTPromiseResolveBlock)resolve
144
+ reject:(RCTPromiseRejectBlock)reject) {
145
+ [RCCommonFunctionality logOutWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
146
+ }
147
+
140
148
  RCT_EXPORT_METHOD(identify:(nullable NSString *)appUserID
141
149
  resolve:(RCTPromiseResolveBlock)resolve
142
150
  reject:(RCTPromiseRejectBlock)reject) {
151
+ #pragma GCC diagnostic push
152
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
143
153
  [RCCommonFunctionality identify:appUserID
144
154
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
155
+ #pragma GCC diagnostic pop
145
156
  }
146
157
 
147
158
  RCT_REMAP_METHOD(reset,
148
159
  resetWithResolve:(RCTPromiseResolveBlock)resolve
149
160
  reject:(RCTPromiseRejectBlock)reject) {
161
+ #pragma GCC diagnostic push
162
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
150
163
  [RCCommonFunctionality resetWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
164
+ #pragma GCC diagnostic pop
151
165
  }
152
166
 
153
167
  RCT_REMAP_METHOD(setDebugLogsEnabled,
@@ -173,15 +187,13 @@ RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automati
173
187
 
174
188
  RCT_REMAP_METHOD(isAnonymous,
175
189
  isAnonymousWithResolve:(RCTPromiseResolveBlock)resolve
176
- reject:(RCTPromiseRejectBlock)reject)
177
- {
190
+ reject:(RCTPromiseRejectBlock)reject) {
178
191
  resolve(@([RCCommonFunctionality isAnonymous]));
179
192
  }
180
193
 
181
194
  RCT_EXPORT_METHOD(makeDeferredPurchase:(nonnull NSNumber *)callbackID
182
195
  resolve:(RCTPromiseResolveBlock)resolve
183
- reject:(RCTPromiseRejectBlock)reject)
184
- {
196
+ reject:(RCTPromiseRejectBlock)reject) {
185
197
  RCDeferredPromotionalPurchaseBlock defermentBlock = [self.defermentBlocks objectAtIndex:[callbackID integerValue]];
186
198
  [RCCommonFunctionality makeDeferredPurchase:defermentBlock
187
199
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
@@ -189,8 +201,7 @@ RCT_EXPORT_METHOD(makeDeferredPurchase:(nonnull NSNumber *)callbackID
189
201
 
190
202
  RCT_EXPORT_METHOD(checkTrialOrIntroductoryPriceEligibility:(NSArray *)products
191
203
  resolve:(RCTPromiseResolveBlock)resolve
192
- reject:(RCTPromiseRejectBlock)reject)
193
- {
204
+ reject:(RCTPromiseRejectBlock)reject) {
194
205
  [RCCommonFunctionality checkTrialOrIntroductoryPriceEligibility:products
195
206
  completionBlock:^(NSDictionary<NSString *,RCIntroEligibility *> * _Nonnull responseDictionary) {
196
207
  resolve([NSDictionary dictionaryWithDictionary:responseDictionary]);
@@ -201,20 +212,18 @@ RCT_REMAP_METHOD(getPaymentDiscount,
201
212
  getPaymentDiscountForProductIdentifier:(NSString *)productIdentifier
202
213
  discountIdentifier:(nullable NSString *)discountIdentifier
203
214
  resolve:(RCTPromiseResolveBlock)resolve
204
- reject:(RCTPromiseRejectBlock)reject)
205
- {
215
+ reject:(RCTPromiseRejectBlock)reject) {
206
216
  [RCCommonFunctionality paymentDiscountForProductIdentifier:productIdentifier
207
217
  discount:discountIdentifier
208
- completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
218
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve
219
+ reject:reject]];
209
220
  }
210
221
 
211
- RCT_EXPORT_METHOD(invalidatePurchaserInfoCache)
212
- {
222
+ RCT_EXPORT_METHOD(invalidatePurchaserInfoCache) {
213
223
  [RCCommonFunctionality invalidatePurchaserInfoCache];
214
224
  }
215
225
 
216
- RCT_EXPORT_METHOD(presentCodeRedemptionSheet)
217
- {
226
+ RCT_EXPORT_METHOD(presentCodeRedemptionSheet) {
218
227
  if (@available(iOS 14.0, *)) {
219
228
  [RCCommonFunctionality presentCodeRedemptionSheet];
220
229
  } else {
@@ -224,113 +233,103 @@ RCT_EXPORT_METHOD(presentCodeRedemptionSheet)
224
233
 
225
234
  #pragma mark - Subscriber Attributes
226
235
 
227
- RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString)
228
- {
236
+ RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString) {
229
237
  [RCCommonFunctionality setProxyURLString:proxyURLString];
230
238
  }
231
239
 
232
- RCT_EXPORT_METHOD(setAttributes:(NSDictionary *)attributes)
233
- {
240
+ RCT_EXPORT_METHOD(setAttributes:(NSDictionary *)attributes) {
234
241
  [RCCommonFunctionality setAttributes:attributes];
235
242
  }
236
243
 
237
- RCT_EXPORT_METHOD(setEmail:(NSString *)email)
238
- {
244
+ RCT_EXPORT_METHOD(setEmail:(NSString *)email) {
239
245
  [RCCommonFunctionality setEmail:email];
240
246
  }
241
247
 
242
- RCT_EXPORT_METHOD(setPhoneNumber:(NSString *)phoneNumber)
243
- {
248
+ RCT_EXPORT_METHOD(setPhoneNumber:(NSString *)phoneNumber) {
244
249
  [RCCommonFunctionality setPhoneNumber:phoneNumber];
245
250
  }
246
251
 
247
- RCT_EXPORT_METHOD(setDisplayName:(NSString *)displayName)
248
- {
252
+ RCT_EXPORT_METHOD(setDisplayName:(NSString *)displayName) {
249
253
  [RCCommonFunctionality setDisplayName:displayName];
250
254
  }
251
255
 
252
- RCT_EXPORT_METHOD(setPushToken:(NSString *)pushToken)
253
- {
256
+ RCT_EXPORT_METHOD(setPushToken:(NSString *)pushToken) {
254
257
  [RCCommonFunctionality setPushToken:pushToken];
255
258
  }
256
259
 
257
260
  # pragma mark Attribution IDs
258
261
 
259
- RCT_EXPORT_METHOD(collectDeviceIdentifiers)
260
- {
262
+ RCT_EXPORT_METHOD(collectDeviceIdentifiers) {
261
263
  [RCCommonFunctionality collectDeviceIdentifiers];
262
264
  }
263
265
 
264
- RCT_EXPORT_METHOD(setAdjustID:(NSString *)adjustID)
265
- {
266
+ RCT_EXPORT_METHOD(setAdjustID:(NSString *)adjustID) {
266
267
  [RCCommonFunctionality setAdjustID:adjustID];
267
268
  }
268
269
 
269
- RCT_EXPORT_METHOD(setAppsflyerID:(NSString *)appsflyerID)
270
- {
270
+ RCT_EXPORT_METHOD(setAppsflyerID:(NSString *)appsflyerID) {
271
271
  [RCCommonFunctionality setAppsflyerID:appsflyerID];
272
272
  }
273
273
 
274
- RCT_EXPORT_METHOD(setFBAnonymousID:(NSString *)fbAnonymousID)
275
- {
274
+ RCT_EXPORT_METHOD(setFBAnonymousID:(NSString *)fbAnonymousID) {
276
275
  [RCCommonFunctionality setFBAnonymousID:fbAnonymousID];
277
276
  }
278
277
 
279
- RCT_EXPORT_METHOD(setMparticleID:(NSString *)mparticleID)
280
- {
278
+ RCT_EXPORT_METHOD(setMparticleID:(NSString *)mparticleID) {
281
279
  [RCCommonFunctionality setMparticleID:mparticleID];
282
280
  }
283
281
 
284
- RCT_EXPORT_METHOD(setOnesignalID:(NSString *)onesignalID)
285
- {
282
+ RCT_EXPORT_METHOD(setOnesignalID:(NSString *)onesignalID) {
286
283
  [RCCommonFunctionality setOnesignalID:onesignalID];
287
284
  }
288
285
 
289
286
  # pragma mark Campaign parameters
290
287
 
291
- RCT_EXPORT_METHOD(setMediaSource:(NSString *)mediaSource)
292
- {
288
+ RCT_EXPORT_METHOD(setMediaSource:(NSString *)mediaSource) {
293
289
  [RCCommonFunctionality setMediaSource:mediaSource];
294
290
  }
295
291
 
296
- RCT_EXPORT_METHOD(setCampaign:(NSString *)campaign)
297
- {
292
+ RCT_EXPORT_METHOD(setCampaign:(NSString *)campaign) {
298
293
  [RCCommonFunctionality setCampaign:campaign];
299
294
  }
300
295
 
301
- RCT_EXPORT_METHOD(setAdGroup:(NSString *)adGroup)
302
- {
296
+ RCT_EXPORT_METHOD(setAdGroup:(NSString *)adGroup) {
303
297
  [RCCommonFunctionality setAdGroup:adGroup];
304
298
  }
305
299
 
306
- RCT_EXPORT_METHOD(setAd:(NSString *)ad)
307
- {
300
+ RCT_EXPORT_METHOD(setAd:(NSString *)ad) {
308
301
  [RCCommonFunctionality setAd:ad];
309
302
  }
310
303
 
311
- RCT_EXPORT_METHOD(setKeyword:(NSString *)keyword)
312
- {
304
+ RCT_EXPORT_METHOD(setKeyword:(NSString *)keyword) {
313
305
  [RCCommonFunctionality setKeyword:keyword];
314
306
  }
315
307
 
316
- RCT_EXPORT_METHOD(setCreative:(NSString *)creative)
317
- {
308
+ RCT_EXPORT_METHOD(setCreative:(NSString *)creative) {
318
309
  [RCCommonFunctionality setCreative:creative];
319
310
  }
320
311
 
321
-
312
+ RCT_REMAP_METHOD(canMakePayments,
313
+ canMakePaymentsWithFeatures:(NSArray<NSNumber *> *)features
314
+ resolve:(RCTPromiseResolveBlock)resolve
315
+ reject:(RCTPromiseRejectBlock)reject) {
316
+ resolve(@([RCCommonFunctionality canMakePaymentsWithFeatures:features]));
317
+ }
318
+
322
319
  #pragma mark -
323
320
  #pragma mark Delegate Methods
324
321
  - (void)purchases:(RCPurchases *)purchases didReceiveUpdatedPurchaserInfo:(RCPurchaserInfo *)purchaserInfo {
325
322
  [self sendEventWithName:RNPurchasesPurchaserInfoUpdatedEvent body:purchaserInfo.dictionary];
326
323
  }
327
324
 
328
- - (void)purchases:(RCPurchases *)purchases shouldPurchasePromoProduct:(SKProduct *)product defermentBlock:(RCDeferredPromotionalPurchaseBlock)makeDeferredPurchase {
325
+ - (void) purchases:(RCPurchases *)purchases
326
+ shouldPurchasePromoProduct:(SKProduct *)product
327
+ defermentBlock:(RCDeferredPromotionalPurchaseBlock)makeDeferredPurchase {
329
328
  if (!self.defermentBlocks) {
330
329
  self.defermentBlocks = [NSMutableArray array];
331
330
  }
332
331
  [self.defermentBlocks addObject:makeDeferredPurchase];
333
- NSInteger position = [self.defermentBlocks count]-1;
332
+ NSInteger position = [self.defermentBlocks count] - 1;
334
333
  [self sendEventWithName:RNPurchasesShouldPurchasePromoProductEvent body:@{@"callbackID": @(position)}];
335
334
  }
336
335
 
@@ -341,11 +340,11 @@ RCT_EXPORT_METHOD(setCreative:(NSString *)creative)
341
340
  reject([NSString stringWithFormat: @"%ld", (long)error.code], error.localizedDescription, error);
342
341
  }
343
342
 
344
- - (void (^)(NSDictionary *, RCErrorContainer *))getResponseCompletionBlockWithResolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
345
- {
343
+ - (void (^)(NSDictionary *, RCErrorContainer *))getResponseCompletionBlockWithResolve:(RCTPromiseResolveBlock)resolve
344
+ reject:(RCTPromiseRejectBlock)reject {
346
345
  return ^(NSDictionary *_Nullable responseDictionary, RCErrorContainer *_Nullable error) {
347
346
  if (error) {
348
- reject([NSString stringWithFormat: @"%ld", (long)error.code], error.message, error.error);
347
+ reject([NSString stringWithFormat:@"%ld", (long) error.code], error.message, error.error);
349
348
  } else if (responseDictionary) {
350
349
  resolve([NSDictionary dictionaryWithDictionary:responseDictionary]);
351
350
  } else {
@@ -359,7 +358,7 @@ RCT_EXPORT_METHOD(setCreative:(NSString *)creative)
359
358
  }
360
359
 
361
360
  - (NSString *)platformFlavorVersion {
362
- return @"4.1.4";
361
+ return @"4.3.2";
363
362
  }
364
363
 
365
364
  @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": "4.1.4",
4
+ "version": "4.3.2",
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",
package/scripts/build.js CHANGED
@@ -5,11 +5,11 @@ if (os.type() === "Linux") {
5
5
  console.log("Skipping iOS Dependencies");
6
6
  } else if (os.type() === "Darwin") {
7
7
  const downloadProcess = exec(
8
- "./scripts/download-purchases-framework.sh 3.11.1"
8
+ "./scripts/download-purchases-framework.sh 3.12.3"
9
9
  );
10
10
  downloadProcess.stdout.pipe(process.stdout);
11
11
  const downloadProcessCommon = exec(
12
- "./scripts/download-purchases-common.sh 1.7.1"
12
+ "./scripts/download-purchases-common.sh 1.9.1"
13
13
  );
14
14
  downloadProcessCommon.stdout.pipe(process.stdout);
15
15
  } else if (os.type() === "Windows_NT") {
@@ -684,6 +684,8 @@ NativeModules.RNPurchases = {
684
684
  identify: jest.fn(),
685
685
  setDebugLogsEnabled: jest.fn(),
686
686
  getPurchaserInfo: jest.fn(),
687
+ logIn: jest.fn(),
688
+ logOut: jest.fn(),
687
689
  reset: jest.fn(),
688
690
  syncPurchases: jest.fn(),
689
691
  setFinishTransactions: jest.fn(),
@@ -701,6 +703,7 @@ NativeModules.RNPurchases = {
701
703
  setPhoneNumber: jest.fn(),
702
704
  setDisplayName: jest.fn(),
703
705
  setPushToken: jest.fn(),
706
+ canMakePayments: jest.fn()
704
707
  };
705
708
 
706
709
  jest.mock(