react-native-purchases 9.7.4 → 9.7.6

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", '17.30.1'
28
+ spec.dependency "PurchasesHybridCommon", '17.31.0'
29
29
  spec.swift_version = '5.7'
30
30
  end
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '9.7.4'
32
+ versionName '9.7.6'
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:17.30.1'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:17.31.0'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -50,7 +50,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
50
50
  private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
51
51
  private static final String TRACKED_EVENT = "Purchases-TrackedEvent";
52
52
  public static final String PLATFORM_NAME = "react-native";
53
- public static final String PLUGIN_VERSION = "9.7.4";
53
+ public static final String PLUGIN_VERSION = "9.7.6";
54
54
 
55
55
  private final ReactApplicationContext reactContext;
56
56
 
package/dist/purchases.js CHANGED
@@ -51,10 +51,26 @@ Object.defineProperty(exports, "LOG_LEVEL", { enumerable: true, get: function ()
51
51
  Object.defineProperty(exports, "STOREKIT_VERSION", { enumerable: true, get: function () { return purchases_typescript_internal_2.STOREKIT_VERSION; } });
52
52
  Object.defineProperty(exports, "WebPurchaseRedemptionResultType", { enumerable: true, get: function () { return purchases_typescript_internal_2.WebPurchaseRedemptionResultType; } });
53
53
  var react_native_2 = require("react-native");
54
+ var NATIVE_MODULE_ERROR = "[RevenueCat] Native module (RNPurchases) not found. This can happen if:\n\n" +
55
+ "- You are running in an environment where native modules are unavailable\n" +
56
+ "- The native module failed to initialize\n" +
57
+ "- The package is not properly linked\n\n" +
58
+ "To fix this:\n" +
59
+ "- If using Expo Go, the SDK works in preview mode but native modules are not available. " +
60
+ "For full functionality, create a development build: https://docs.expo.dev/develop/development-builds/create-a-build/\n" +
61
+ "- If using bare React Native, run 'pod install' and rebuild the app\n" +
62
+ "- Check that you have rebuilt the app after installing the package\n";
54
63
  // Get the native module or use the browser implementation
55
64
  var usingBrowserMode = (0, environment_1.shouldUseBrowserMode)();
56
65
  var RNPurchases = usingBrowserMode ? nativeModule_1.browserNativeModuleRNPurchases : react_native_1.NativeModules.RNPurchases;
57
- var eventEmitter = usingBrowserMode ? null : new react_native_1.NativeEventEmitter(RNPurchases);
66
+ // Only create event emitter if native module is available to avoid crash on import
67
+ var eventEmitter = !usingBrowserMode && RNPurchases ? new react_native_1.NativeEventEmitter(RNPurchases) : null;
68
+ // Helper function to check if native module is available - provides better error message than "Cannot read property X of null"
69
+ function throwIfNativeModuleNotAvailable() {
70
+ if (!RNPurchases) {
71
+ throw new Error(NATIVE_MODULE_ERROR);
72
+ }
73
+ }
58
74
  var customerInfoUpdateListeners = [];
59
75
  var shouldPurchasePromoProductListeners = [];
60
76
  var customLogHandler;
@@ -70,8 +86,10 @@ eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.addList
70
86
  });
71
87
  eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.addListener("Purchases-LogHandlerEvent", function (_a) {
72
88
  var logLevel = _a.logLevel, message = _a.message;
73
- var logLevelEnum = purchases_typescript_internal_1.LOG_LEVEL[logLevel];
74
- customLogHandler(logLevelEnum, message);
89
+ if (customLogHandler) {
90
+ var logLevelEnum = purchases_typescript_internal_1.LOG_LEVEL[logLevel];
91
+ customLogHandler(logLevelEnum, message);
92
+ }
75
93
  });
76
94
  eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.addListener("Purchases-TrackedEvent", function (eventDictionary) {
77
95
  trackedEventListeners.forEach(function (listener) { return listener({ eventDictionary: eventDictionary }); });
@@ -100,6 +118,7 @@ var Purchases = /** @class */ (function () {
100
118
  */
101
119
  Purchases.configure = function (_a) {
102
120
  var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.purchasesAreCompletedBy, purchasesAreCompletedBy = _c === void 0 ? purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT : _c, userDefaultsSuiteName = _a.userDefaultsSuiteName, _d = _a.storeKitVersion, storeKitVersion = _d === void 0 ? purchases_typescript_internal_1.STOREKIT_VERSION.DEFAULT : _d, _e = _a.useAmazon, useAmazon = _e === void 0 ? false : _e, _f = _a.shouldShowInAppMessagesAutomatically, shouldShowInAppMessagesAutomatically = _f === void 0 ? true : _f, _g = _a.entitlementVerificationMode, entitlementVerificationMode = _g === void 0 ? purchases_typescript_internal_1.ENTITLEMENT_VERIFICATION_MODE.DISABLED : _g, _h = _a.pendingTransactionsForPrepaidPlansEnabled, pendingTransactionsForPrepaidPlansEnabled = _h === void 0 ? false : _h, _j = _a.diagnosticsEnabled, diagnosticsEnabled = _j === void 0 ? false : _j, _k = _a.automaticDeviceIdentifierCollectionEnabled, automaticDeviceIdentifierCollectionEnabled = _k === void 0 ? true : _k, preferredUILocaleOverride = _a.preferredUILocaleOverride;
121
+ throwIfNativeModuleNotAvailable();
103
122
  if (!customLogHandler) {
104
123
  this.setLogHandler(function (logLevel, message) {
105
124
  switch (logLevel) {
@@ -1608,6 +1627,10 @@ var Purchases = /** @class */ (function () {
1608
1627
  */
1609
1628
  Purchases.canMakePayments = function (features) {
1610
1629
  if (features === void 0) { features = []; }
1630
+ if (!RNPurchases) {
1631
+ // Native module not available, so payments cannot be made
1632
+ return Promise.resolve(false);
1633
+ }
1611
1634
  return RNPurchases.canMakePayments(features);
1612
1635
  };
1613
1636
  /**
@@ -1862,6 +1885,12 @@ var Purchases = /** @class */ (function () {
1862
1885
  * @returns {Promise<Boolean>} promise with boolean response
1863
1886
  */
1864
1887
  Purchases.isConfigured = function () {
1888
+ if (!RNPurchases) {
1889
+ // Native module not available, so SDK cannot be configured
1890
+ // tslint:disable-next-line:no-console
1891
+ console.warn("[RevenueCat] isConfigured() returning false: Native module not available");
1892
+ return Promise.resolve(false);
1893
+ }
1865
1894
  return RNPurchases.isConfigured();
1866
1895
  };
1867
1896
  Purchases.throwIfNotConfigured = function () {
package/ios/RNPurchases.m CHANGED
@@ -28,7 +28,7 @@ typedef void (^StartPurchaseBlock)(PurchaseCompletedBlock);
28
28
  NSString *RNPurchasesCustomerInfoUpdatedEvent = @"Purchases-CustomerInfoUpdated";
29
29
  NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchasePromoProduct";
30
30
  NSString *RNPurchasesLogHandlerEvent = @"Purchases-LogHandlerEvent";
31
-
31
+ NSString *RNPurchasesTrackedEvent = @"Purchases-TrackedEvent";
32
32
 
33
33
  @implementation RNPurchases
34
34
 
@@ -39,7 +39,8 @@ NSString *RNPurchasesLogHandlerEvent = @"Purchases-LogHandlerEvent";
39
39
  - (NSArray<NSString *> *)supportedEvents {
40
40
  return @[RNPurchasesCustomerInfoUpdatedEvent,
41
41
  RNPurchasesShouldPurchasePromoProductEvent,
42
- RNPurchasesLogHandlerEvent];
42
+ RNPurchasesLogHandlerEvent,
43
+ RNPurchasesTrackedEvent];
43
44
  }
44
45
 
45
46
  - (void)sendEventWithName:(NSString *)name body:(id)body {
@@ -672,7 +673,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
672
673
  }
673
674
 
674
675
  - (NSString *)platformFlavorVersion {
675
- return @"9.7.4";
676
+ return @"9.7.6";
676
677
  }
677
678
 
678
679
  @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": "9.7.4",
4
+ "version": "9.7.6",
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",
@@ -114,7 +114,7 @@
114
114
  ]
115
115
  },
116
116
  "dependencies": {
117
- "@revenuecat/purchases-js-hybrid-mappings": "17.30.1",
118
- "@revenuecat/purchases-typescript-internal": "17.30.1"
117
+ "@revenuecat/purchases-js-hybrid-mappings": "17.31.0",
118
+ "@revenuecat/purchases-typescript-internal": "17.31.0"
119
119
  }
120
120
  }