react-native-purchases 10.10.2 → 10.12.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.
@@ -25,6 +25,6 @@ Pod::Spec.new do |spec|
25
25
  ]
26
26
 
27
27
  spec.dependency "React-Core"
28
- spec.dependency "PurchasesHybridCommon", '19.3.1'
28
+ spec.dependency "PurchasesHybridCommon", '19.6.0'
29
29
  spec.swift_version = '5.7'
30
30
  end
@@ -35,7 +35,7 @@ android {
35
35
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
36
36
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
37
37
  versionCode 1
38
- versionName '10.10.2'
38
+ versionName '10.12.0'
39
39
  }
40
40
 
41
41
  buildTypes {
@@ -127,6 +127,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
127
127
  dependencies {
128
128
  //noinspection GradleDynamicVersion
129
129
  api 'com.facebook.react:react-native:+'
130
- implementation 'com.revenuecat.purchases:purchases-hybrid-common:19.3.1'
130
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:19.6.0'
131
131
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
132
132
  }
@@ -51,7 +51,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
51
51
  private static final String TRACKED_EVENT = "Purchases-TrackedEvent";
52
52
  private static final String DEBUG_EVENT = "Purchases-DebugEvent";
53
53
  public static final String PLATFORM_NAME = "react-native";
54
- public static final String PLUGIN_VERSION = "10.10.2";
54
+ public static final String PLUGIN_VERSION = "10.12.0";
55
55
 
56
56
  private final ReactApplicationContext reactContext;
57
57
 
@@ -96,7 +96,9 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
96
96
  boolean pendingTransactionsForPrepaidPlansEnabled,
97
97
  boolean diagnosticsEnabled,
98
98
  boolean automaticDeviceIdentifierCollectionEnabled,
99
- @Nullable String preferredUILocaleOverride) {
99
+ @Nullable String preferredUILocaleOverride,
100
+ boolean useExternalPurchaseCustomLinks,
101
+ boolean enableExternalPurchasesInSimulator) {
100
102
  PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
101
103
  Store store = Store.PLAY_STORE;
102
104
  if ("GALAXY".equals(storeString)) {
@@ -665,6 +667,16 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
665
667
  CommonKt.trackAdFailedToLoad(data.toHashMap());
666
668
  }
667
669
 
670
+ @ReactMethod
671
+ public void trackRewardedAdPromptShown(ReadableMap data) {
672
+ CommonKt.trackRewardedAdPromptShown(data.toHashMap());
673
+ }
674
+
675
+ @ReactMethod
676
+ public void trackRewardedAdPromptAccepted(ReadableMap data) {
677
+ CommonKt.trackRewardedAdPromptAccepted(data.toHashMap());
678
+ }
679
+
668
680
  @ReactMethod
669
681
  public void generateRewardVerificationToken(String impressionId, final Promise promise) {
670
682
  promise.resolve(convertMapToWriteableMap(CommonKt.generateRewardVerificationToken(impressionId)));
@@ -4,7 +4,7 @@ import type { RewardedAdTrackingMetadata } from '../purchases';
4
4
  * Browser implementation of the native module. This will be used in the browser and Expo Go.
5
5
  */
6
6
  export declare const browserNativeModuleRNPurchases: {
7
- setupPurchases: (apiKey: string, appUserID: string | null, _purchasesAreCompletedBy: string | null, _userDefaultsSuiteName: string | null, _storeKitVersion: string | null, _useAmazon: boolean, _store: string | null, _galaxyBillingMode: string | null, _shouldShowInAppMessagesAutomatically: boolean, _entitlementVerificationMode: string | null, _pendingTransactionsForPrepaidPlansEnabled: boolean, _diagnosticsEnabled: boolean, _automaticDeviceIdentifierCollectionEnabled: boolean, _preferredUILocaleOverride: string | null) => void;
7
+ setupPurchases: (apiKey: string, appUserID: string | null, _purchasesAreCompletedBy: string | null, _userDefaultsSuiteName: string | null, _storeKitVersion: string | null, _useAmazon: boolean, _store: string | null, _galaxyBillingMode: string | null, _shouldShowInAppMessagesAutomatically: boolean, _entitlementVerificationMode: string | null, _pendingTransactionsForPrepaidPlansEnabled: boolean, _diagnosticsEnabled: boolean, _automaticDeviceIdentifierCollectionEnabled: boolean, _preferredUILocaleOverride: string | null, _useExternalPurchaseCustomLinks: boolean, _enableExternalPurchasesInSimulator: boolean) => void;
8
8
  setAllowSharingStoreAccount: (_allowSharing: boolean) => Promise<void>;
9
9
  setSimulatesAskToBuyInSandbox: (_simulatesAskToBuyInSandbox: boolean) => Promise<void>;
10
10
  getOfferings: () => Promise<import("@revenuecat/purchases-typescript-internal").PurchasesOfferings>;
@@ -93,6 +93,8 @@ export declare const browserNativeModuleRNPurchases: {
93
93
  trackAdLoaded: (_data: any) => Promise<void>;
94
94
  trackAdRevenue: (_data: any) => Promise<void>;
95
95
  trackAdFailedToLoad: (_data: any) => Promise<void>;
96
+ trackRewardedAdPromptShown: (_data: any) => Promise<void>;
97
+ trackRewardedAdPromptAccepted: (_data: any) => Promise<void>;
96
98
  generateRewardVerificationToken: (_impressionId: string) => Promise<void>;
97
99
  pollRewardVerification: (_clientTransactionId: string, _trackingMetadata?: RewardedAdTrackingMetadata) => Promise<void>;
98
100
  };
@@ -43,12 +43,12 @@ var typeGuards_1 = require("./typeGuards");
43
43
  var environment_1 = require("../utils/environment");
44
44
  var utils_1 = require("./utils");
45
45
  var purchaseSimulatedPackageHelper_1 = require("./simulatedstore/purchaseSimulatedPackageHelper");
46
- var packageVersion = '10.10.2';
46
+ var packageVersion = '10.12.0';
47
47
  /**
48
48
  * Browser implementation of the native module. This will be used in the browser and Expo Go.
49
49
  */
50
50
  exports.browserNativeModuleRNPurchases = {
51
- setupPurchases: function (apiKey, appUserID, _purchasesAreCompletedBy, _userDefaultsSuiteName, _storeKitVersion, _useAmazon, _store, _galaxyBillingMode, _shouldShowInAppMessagesAutomatically, _entitlementVerificationMode, _pendingTransactionsForPrepaidPlansEnabled, _diagnosticsEnabled, _automaticDeviceIdentifierCollectionEnabled, _preferredUILocaleOverride) {
51
+ setupPurchases: function (apiKey, appUserID, _purchasesAreCompletedBy, _userDefaultsSuiteName, _storeKitVersion, _useAmazon, _store, _galaxyBillingMode, _shouldShowInAppMessagesAutomatically, _entitlementVerificationMode, _pendingTransactionsForPrepaidPlansEnabled, _diagnosticsEnabled, _automaticDeviceIdentifierCollectionEnabled, _preferredUILocaleOverride, _useExternalPurchaseCustomLinks, _enableExternalPurchasesInSimulator) {
52
52
  try {
53
53
  // Make sure that when running in Expo Go or Rork sandbox a web-compatible API key is used, because the underlying purchases-js error message isn't super clear when a non-compatible API key type is used in this case
54
54
  var webPlatformCompatibleApiKeyPrefixList = ['test_', 'rcb_'];
@@ -645,6 +645,18 @@ exports.browserNativeModuleRNPurchases = {
645
645
  return [2 /*return*/];
646
646
  });
647
647
  }); },
648
+ trackRewardedAdPromptShown: function (_data) { return __awaiter(void 0, void 0, void 0, function () {
649
+ return __generator(this, function (_a) {
650
+ (0, utils_1.methodNotSupportedOnWeb)('trackRewardedAdPromptShown');
651
+ return [2 /*return*/];
652
+ });
653
+ }); },
654
+ trackRewardedAdPromptAccepted: function (_data) { return __awaiter(void 0, void 0, void 0, function () {
655
+ return __generator(this, function (_a) {
656
+ (0, utils_1.methodNotSupportedOnWeb)('trackRewardedAdPromptAccepted');
657
+ return [2 /*return*/];
658
+ });
659
+ }); },
648
660
  generateRewardVerificationToken: function (_impressionId) { return __awaiter(void 0, void 0, void 0, function () {
649
661
  return __generator(this, function (_a) {
650
662
  (0, utils_1.methodNotSupportedOnWeb)('generateRewardVerificationToken');
@@ -114,6 +114,16 @@ export interface AdFailedToLoadData {
114
114
  mediatorErrorCode?: number | null;
115
115
  placement?: string | null;
116
116
  }
117
+ export interface AdRewardPromptShownData {
118
+ mediatorName: AdMediatorName;
119
+ adUnitId: string;
120
+ placement?: string | null;
121
+ }
122
+ export interface AdRewardPromptAcceptedData {
123
+ mediatorName: AdMediatorName;
124
+ adUnitId: string;
125
+ placement?: string | null;
126
+ }
117
127
  /**
118
128
  * Token generated for a rewarded ad impression. Pass `clientTransactionId` to
119
129
  * the ad network as server-side verification custom data, then to
@@ -284,6 +294,8 @@ export default class Purchases {
284
294
  * @param {boolean} [diagnosticsEnabled=false] An optional boolean. Set this to true to enable SDK diagnostics.
285
295
  * @param {boolean} [automaticDeviceIdentifierCollectionEnabled=true] An optional boolean. Set this to true to allow the collection of identifiers when setting the identifier for an attribution network.
286
296
  * @param {String?} [preferredUILocaleOverride] An optional string. Set this to the preferred UI locale to use for RevenueCat UI components.
297
+ * @param {boolean} [useExternalPurchaseCustomLinks=false] Experimental. An optional boolean. iOS-only. Set this to true to make web purchase buttons that open in the external browser go through Apple's external purchase custom link flow.
298
+ * @param {boolean} [enableExternalPurchasesInSimulator=true] Experimental. An optional boolean. iOS-only. Set this to false to make the simulator behave as a device does for a customer who is not eligible for external purchases.
287
299
  *
288
300
  * @warning If you use purchasesAreCompletedBy=PurchasesAreCompletedByMyApp, you must also provide a value for storeKitVersion.
289
301
  */
@@ -1118,4 +1130,6 @@ export declare class PurchasesAdTracker {
1118
1130
  trackAdLoaded(data: AdLoadedData): Promise<void>;
1119
1131
  trackAdRevenue(data: AdRevenueData): Promise<void>;
1120
1132
  trackAdFailedToLoad(data: AdFailedToLoadData): Promise<void>;
1133
+ trackRewardedAdPromptShown(data: AdRewardPromptShownData): Promise<void>;
1134
+ trackRewardedAdPromptAccepted(data: AdRewardPromptAcceptedData): Promise<void>;
1121
1135
  }
package/dist/purchases.js CHANGED
@@ -167,12 +167,14 @@ var Purchases = /** @class */ (function () {
167
167
  * @param {boolean} [diagnosticsEnabled=false] An optional boolean. Set this to true to enable SDK diagnostics.
168
168
  * @param {boolean} [automaticDeviceIdentifierCollectionEnabled=true] An optional boolean. Set this to true to allow the collection of identifiers when setting the identifier for an attribution network.
169
169
  * @param {String?} [preferredUILocaleOverride] An optional string. Set this to the preferred UI locale to use for RevenueCat UI components.
170
+ * @param {boolean} [useExternalPurchaseCustomLinks=false] Experimental. An optional boolean. iOS-only. Set this to true to make web purchase buttons that open in the external browser go through Apple's external purchase custom link flow.
171
+ * @param {boolean} [enableExternalPurchasesInSimulator=true] Experimental. An optional boolean. iOS-only. Set this to false to make the simulator behave as a device does for a customer who is not eligible for external purchases.
170
172
  *
171
173
  * @warning If you use purchasesAreCompletedBy=PurchasesAreCompletedByMyApp, you must also provide a value for storeKitVersion.
172
174
  */
173
175
  Purchases.configure = function (configuration) {
174
- var apiKey = configuration.apiKey, _a = configuration.appUserID, appUserID = _a === void 0 ? null : _a, _b = configuration.purchasesAreCompletedBy, purchasesAreCompletedBy = _b === void 0 ? purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT : _b, userDefaultsSuiteName = configuration.userDefaultsSuiteName, _c = configuration.storeKitVersion, storeKitVersion = _c === void 0 ? purchases_typescript_internal_1.STOREKIT_VERSION.DEFAULT : _c, _d = configuration.useAmazon, useAmazon = _d === void 0 ? false : _d, _e = configuration.shouldShowInAppMessagesAutomatically, shouldShowInAppMessagesAutomatically = _e === void 0 ? true : _e, _f = configuration.entitlementVerificationMode, entitlementVerificationMode = _f === void 0 ? purchases_typescript_internal_1.ENTITLEMENT_VERIFICATION_MODE.DISABLED : _f, _g = configuration.pendingTransactionsForPrepaidPlansEnabled, pendingTransactionsForPrepaidPlansEnabled = _g === void 0 ? false : _g, _h = configuration.diagnosticsEnabled, diagnosticsEnabled = _h === void 0 ? false : _h, _j = configuration.automaticDeviceIdentifierCollectionEnabled, automaticDeviceIdentifierCollectionEnabled = _j === void 0 ? true : _j, preferredUILocaleOverride = configuration.preferredUILocaleOverride;
175
- var _k = configuration, store = _k.store, galaxyBillingMode = _k.galaxyBillingMode;
176
+ var apiKey = configuration.apiKey, _a = configuration.appUserID, appUserID = _a === void 0 ? null : _a, _b = configuration.purchasesAreCompletedBy, purchasesAreCompletedBy = _b === void 0 ? purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT : _b, userDefaultsSuiteName = configuration.userDefaultsSuiteName, _c = configuration.storeKitVersion, storeKitVersion = _c === void 0 ? purchases_typescript_internal_1.STOREKIT_VERSION.DEFAULT : _c, _d = configuration.useAmazon, useAmazon = _d === void 0 ? false : _d, _e = configuration.shouldShowInAppMessagesAutomatically, shouldShowInAppMessagesAutomatically = _e === void 0 ? true : _e, _f = configuration.entitlementVerificationMode, entitlementVerificationMode = _f === void 0 ? purchases_typescript_internal_1.ENTITLEMENT_VERIFICATION_MODE.DISABLED : _f, _g = configuration.pendingTransactionsForPrepaidPlansEnabled, pendingTransactionsForPrepaidPlansEnabled = _g === void 0 ? false : _g, _h = configuration.diagnosticsEnabled, diagnosticsEnabled = _h === void 0 ? false : _h, _j = configuration.automaticDeviceIdentifierCollectionEnabled, automaticDeviceIdentifierCollectionEnabled = _j === void 0 ? true : _j, preferredUILocaleOverride = configuration.preferredUILocaleOverride, _k = configuration.useExternalPurchaseCustomLinks, useExternalPurchaseCustomLinks = _k === void 0 ? false : _k, _l = configuration.enableExternalPurchasesInSimulator, enableExternalPurchasesInSimulator = _l === void 0 ? true : _l;
177
+ var _m = configuration, store = _m.store, galaxyBillingMode = _m.galaxyBillingMode;
176
178
  throwIfNativeModuleNotAvailable();
177
179
  if (!customLogHandler) {
178
180
  this.setLogHandler(function (logLevel, message) {
@@ -225,7 +227,7 @@ var Purchases = /** @class */ (function () {
225
227
  console.warn("Warning: You should provide the specific StoreKit version you're using in your implementation when configuring PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP, and not rely on the DEFAULT.");
226
228
  }
227
229
  }
228
- RNPurchases.setupPurchases(apiKey, appUserID, purchasesCompletedByToUse, userDefaultsSuiteName, storeKitVersionToUse, useAmazon, store, galaxyBillingMode, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled, diagnosticsEnabled, automaticDeviceIdentifierCollectionEnabled, preferredUILocaleOverride);
230
+ RNPurchases.setupPurchases(apiKey, appUserID, purchasesCompletedByToUse, userDefaultsSuiteName, storeKitVersionToUse, useAmazon, store, galaxyBillingMode, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled, diagnosticsEnabled, automaticDeviceIdentifierCollectionEnabled, preferredUILocaleOverride, useExternalPurchaseCustomLinks, enableExternalPurchasesInSimulator);
229
231
  };
230
232
  /**
231
233
  * @deprecated, configure behavior through the RevenueCat dashboard (app.revenuecat.com) instead.
@@ -2361,6 +2363,32 @@ var PurchasesAdTracker = /** @class */ (function () {
2361
2363
  });
2362
2364
  });
2363
2365
  };
2366
+ PurchasesAdTracker.prototype.trackRewardedAdPromptShown = function (data) {
2367
+ return __awaiter(this, void 0, void 0, function () {
2368
+ return __generator(this, function (_a) {
2369
+ switch (_a.label) {
2370
+ case 0: return [4 /*yield*/, throwIfNotConfigured()];
2371
+ case 1:
2372
+ _a.sent();
2373
+ RNPurchases.trackRewardedAdPromptShown(data);
2374
+ return [2 /*return*/];
2375
+ }
2376
+ });
2377
+ });
2378
+ };
2379
+ PurchasesAdTracker.prototype.trackRewardedAdPromptAccepted = function (data) {
2380
+ return __awaiter(this, void 0, void 0, function () {
2381
+ return __generator(this, function (_a) {
2382
+ switch (_a.label) {
2383
+ case 0: return [4 /*yield*/, throwIfNotConfigured()];
2384
+ case 1:
2385
+ _a.sent();
2386
+ RNPurchases.trackRewardedAdPromptAccepted(data);
2387
+ return [2 /*return*/];
2388
+ }
2389
+ });
2390
+ });
2391
+ };
2364
2392
  return PurchasesAdTracker;
2365
2393
  }());
2366
2394
  exports.PurchasesAdTracker = PurchasesAdTracker;
package/ios/RNPurchases.m CHANGED
@@ -89,7 +89,9 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
89
89
  pendingTransactionsForPrepaidPlansEnabled:(BOOL)pendingTransactionsForPrepaidPlansEnabled
90
90
  diagnosticsEnabled:(BOOL)diagnosticsEnabled
91
91
  automaticDeviceIdentifierCollectionEnabled:(BOOL)automaticDeviceIdentifierCollectionEnabled
92
- preferredUILocaleOverride:(nullable NSString *)preferredUILocaleOverride) {
92
+ preferredUILocaleOverride:(nullable NSString *)preferredUILocaleOverride
93
+ useExternalPurchaseCustomLinks:(BOOL)useExternalPurchaseCustomLinks
94
+ enableExternalPurchasesInSimulator:(BOOL)enableExternalPurchasesInSimulator) {
93
95
  RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey.mappingNSNullToNil
94
96
  appUserID:appUserID.mappingNSNullToNil
95
97
  purchasesAreCompletedBy:purchasesAreCompletedBy.mappingNSNullToNil
@@ -102,7 +104,9 @@ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
102
104
  verificationMode:entitlementVerificationMode.mappingNSNullToNil
103
105
  diagnosticsEnabled:diagnosticsEnabled
104
106
  automaticDeviceIdentifierCollectionEnabled:automaticDeviceIdentifierCollectionEnabled
105
- preferredLocale:preferredUILocaleOverride.mappingNSNullToNil];
107
+ preferredLocale:preferredUILocaleOverride.mappingNSNullToNil
108
+ useExternalPurchaseCustomLinks:useExternalPurchaseCustomLinks
109
+ enableExternalPurchasesInSimulator:enableExternalPurchasesInSimulator];
106
110
  purchases.delegate = self;
107
111
  }
108
112
 
@@ -697,6 +701,22 @@ RCT_EXPORT_METHOD(trackAdFailedToLoad:(NSDictionary *)data) {
697
701
  }
698
702
  }
699
703
 
704
+ RCT_EXPORT_METHOD(trackRewardedAdPromptShown:(NSDictionary *)data) {
705
+ if (@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)) {
706
+ [RCCommonFunctionality trackRewardedAdPromptShown:data];
707
+ } else {
708
+ NSLog(@"[Purchases] Warning: tried to call trackRewardedAdPromptShown, but it's only available on iOS 15.0 or greater.");
709
+ }
710
+ }
711
+
712
+ RCT_EXPORT_METHOD(trackRewardedAdPromptAccepted:(NSDictionary *)data) {
713
+ if (@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)) {
714
+ [RCCommonFunctionality trackRewardedAdPromptAccepted:data];
715
+ } else {
716
+ NSLog(@"[Purchases] Warning: tried to call trackRewardedAdPromptAccepted, but it's only available on iOS 15.0 or greater.");
717
+ }
718
+ }
719
+
700
720
  RCT_EXPORT_METHOD(generateRewardVerificationToken:(NSString *)impressionId
701
721
  resolve:(RCTPromiseResolveBlock)resolve
702
722
  reject:(RCTPromiseRejectBlock)reject) {
@@ -785,7 +805,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
785
805
  }
786
806
 
787
807
  - (NSString *)platformFlavorVersion {
788
- return @"10.10.2";
808
+ return @"10.12.0";
789
809
  }
790
810
 
791
811
  @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": "10.10.2",
4
+ "version": "10.12.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
  "module": "dist/index.js",
@@ -118,7 +118,7 @@
118
118
  ]
119
119
  },
120
120
  "dependencies": {
121
- "@revenuecat/purchases-js-hybrid-mappings": "19.3.1",
122
- "@revenuecat/purchases-typescript-internal": "19.3.1"
121
+ "@revenuecat/purchases-js-hybrid-mappings": "19.6.0",
122
+ "@revenuecat/purchases-typescript-internal": "19.6.0"
123
123
  }
124
124
  }