react-native-purchases 9.0.0 → 9.1.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", '15.0.0'
28
+ spec.dependency "PurchasesHybridCommon", '16.0.2'
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.0.0'
32
+ versionName '9.1.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:15.0.0'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:16.0.2'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
@@ -47,7 +47,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
47
47
  private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
48
48
  private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
49
49
  public static final String PLATFORM_NAME = "react-native";
50
- public static final String PLUGIN_VERSION = "9.0.0";
50
+ public static final String PLUGIN_VERSION = "9.1.0";
51
51
 
52
52
  private final ReactApplicationContext reactContext;
53
53
 
@@ -338,6 +338,29 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
338
338
  promise.resolve(Purchases.isConfigured());
339
339
  }
340
340
 
341
+ //================================================================================
342
+ // Virtual Currencies
343
+ //================================================================================
344
+ @ReactMethod
345
+ public void getVirtualCurrencies(final Promise promise) {
346
+ CommonKt.getVirtualCurrencies(getOnResult(promise));
347
+ }
348
+
349
+ @ReactMethod
350
+ public void invalidateVirtualCurrenciesCache() {
351
+ CommonKt.invalidateVirtualCurrenciesCache();
352
+ }
353
+
354
+ @ReactMethod
355
+ public void getCachedVirtualCurrencies(final Promise promise) {
356
+ Map<String, ?> cachedVirtualCurrencies = CommonKt.getCachedVirtualCurrencies();
357
+ if (cachedVirtualCurrencies == null) {
358
+ promise.resolve(null);
359
+ } else {
360
+ promise.resolve(convertMapToWriteableMap(cachedVirtualCurrencies));
361
+ }
362
+ }
363
+
341
364
  //================================================================================
342
365
  // Subscriber Attributes
343
366
  //================================================================================
@@ -1,4 +1,4 @@
1
- import { CustomerInfo, MakePurchaseResult, PurchasesStoreTransaction, WebPurchaseRedemptionResultType, PurchasesStoreProduct, PurchasesOffering, PurchasesOfferings } from '@revenuecat/purchases-typescript-internal';
1
+ import { CustomerInfo, MakePurchaseResult, PurchasesStoreTransaction, WebPurchaseRedemptionResultType, PurchasesStoreProduct, PurchasesOffering, PurchasesOfferings, PurchasesVirtualCurrencies } from '@revenuecat/purchases-typescript-internal';
2
2
  /**
3
3
  * Preview implementation of the native module for Preview API mode, i.e. for environments where native modules are not available
4
4
  * (like Expo Go).
@@ -79,4 +79,7 @@ export declare const previewNativeModuleRNPurchases: {
79
79
  result: WebPurchaseRedemptionResultType;
80
80
  customerInfo: CustomerInfo;
81
81
  }>;
82
+ getVirtualCurrencies: () => Promise<PurchasesVirtualCurrencies>;
83
+ invalidateVirtualCurrenciesCache: () => Promise<void>;
84
+ getCachedVirtualCurrencies: () => Promise<PurchasesVirtualCurrencies>;
82
85
  };
@@ -125,6 +125,9 @@ var previewOfferings = {
125
125
  },
126
126
  current: previewOffering
127
127
  };
128
+ var previewVirtualCurrencies = {
129
+ all: {}
130
+ };
128
131
  /**
129
132
  * Preview implementation of the native module for Preview API mode, i.e. for environments where native modules are not available
130
133
  * (like Expo Go).
@@ -483,4 +486,19 @@ exports.previewNativeModuleRNPurchases = {
483
486
  }];
484
487
  });
485
488
  }); },
489
+ getVirtualCurrencies: function () { return __awaiter(void 0, void 0, void 0, function () {
490
+ return __generator(this, function (_a) {
491
+ return [2 /*return*/, previewVirtualCurrencies];
492
+ });
493
+ }); },
494
+ invalidateVirtualCurrenciesCache: function () { return __awaiter(void 0, void 0, void 0, function () {
495
+ return __generator(this, function (_a) {
496
+ return [2 /*return*/];
497
+ });
498
+ }); },
499
+ getCachedVirtualCurrencies: function () { return __awaiter(void 0, void 0, void 0, function () {
500
+ return __generator(this, function (_a) {
501
+ return [2 /*return*/, previewVirtualCurrencies];
502
+ });
503
+ }); }
486
504
  };
@@ -1,4 +1,4 @@
1
- import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError, CustomerInfo, PurchasesEntitlementInfo, PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo, PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, STOREKIT_VERSION, PurchasesStoreTransaction, PurchasesOffering, PURCHASES_ARE_COMPLETED_BY_TYPE, PurchasesWinBackOffer, WebPurchaseRedemption, WebPurchaseRedemptionResult, Storefront } from "@revenuecat/purchases-typescript-internal";
1
+ import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError, CustomerInfo, PurchasesEntitlementInfo, PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo, PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, STOREKIT_VERSION, PurchasesStoreTransaction, PurchasesOffering, PURCHASES_ARE_COMPLETED_BY_TYPE, PurchasesVirtualCurrencies, PurchasesWinBackOffer, WebPurchaseRedemption, WebPurchaseRedemptionResult, Storefront } from "@revenuecat/purchases-typescript-internal";
2
2
  export { PURCHASE_TYPE, PurchasesAreCompletedBy, PurchasesAreCompletedByMyApp, PURCHASES_ARE_COMPLETED_BY_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, STOREKIT_VERSION, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, } from "@revenuecat/purchases-typescript-internal";
3
3
  export default class Purchases {
4
4
  /**
@@ -780,6 +780,33 @@ export default class Purchases {
780
780
  * WebPurchaseRedemption parameter is passed or Purchases is not configured.
781
781
  */
782
782
  static redeemWebPurchase(webPurchaseRedemption: WebPurchaseRedemption): Promise<WebPurchaseRedemptionResult>;
783
+ /**
784
+ * Fetches the virtual currencies for the current subscriber.
785
+ *
786
+ * @returns {Promise<PurchasesVirtualCurrencies>} A PurchasesVirtualCurrencies object containing the subscriber's virtual currencies.
787
+ * The promise will be rejected if configure has not been called yet or if an error occurs.
788
+ */
789
+ static getVirtualCurrencies(): Promise<PurchasesVirtualCurrencies>;
790
+ /**
791
+ * Invalidates the cache for virtual currencies.
792
+ *
793
+ * This is useful for cases where a virtual currency's balance might have been updated
794
+ * outside of the app, like if you decreased a user's balance from the user spending a virtual currency,
795
+ * or if you increased the balance from your backend using the server APIs.
796
+ *
797
+ * @returns {Promise<void>} The promise will be rejected if configure has not been called yet or there's an error
798
+ * invalidating the virtual currencies cache.
799
+ */
800
+ static invalidateVirtualCurrenciesCache(): Promise<void>;
801
+ /**
802
+ * The currently cached [PurchasesVirtualCurrencies] if one is available.
803
+ * This value will remain null until virtual currencies have been fetched at
804
+ * least once with [Purchases.getVirtualCurrencies] or an equivalent function.
805
+ *
806
+ * @returns {Promise<PurchasesVirtualCurrencies | null>} The currently cached virtual currencies for the current subscriber.
807
+ * The promise will be rejected if configure has not been called yet or there's an error.
808
+ */
809
+ static getCachedVirtualCurrencies(): Promise<PurchasesVirtualCurrencies | null>;
783
810
  /**
784
811
  * Check if configure has finished and Purchases has been configured.
785
812
  *
package/dist/purchases.js CHANGED
@@ -1754,6 +1754,74 @@ var Purchases = /** @class */ (function () {
1754
1754
  });
1755
1755
  });
1756
1756
  };
1757
+ /**
1758
+ * Fetches the virtual currencies for the current subscriber.
1759
+ *
1760
+ * @returns {Promise<PurchasesVirtualCurrencies>} A PurchasesVirtualCurrencies object containing the subscriber's virtual currencies.
1761
+ * The promise will be rejected if configure has not been called yet or if an error occurs.
1762
+ */
1763
+ Purchases.getVirtualCurrencies = function () {
1764
+ return __awaiter(this, void 0, void 0, function () {
1765
+ return __generator(this, function (_a) {
1766
+ switch (_a.label) {
1767
+ case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
1768
+ case 1:
1769
+ _a.sent();
1770
+ Purchases.logWarningIfPreviewAPIMode('getVirtualCurrencies');
1771
+ return [2 /*return*/, RNPurchases.getVirtualCurrencies()];
1772
+ }
1773
+ });
1774
+ });
1775
+ };
1776
+ /**
1777
+ * Invalidates the cache for virtual currencies.
1778
+ *
1779
+ * This is useful for cases where a virtual currency's balance might have been updated
1780
+ * outside of the app, like if you decreased a user's balance from the user spending a virtual currency,
1781
+ * or if you increased the balance from your backend using the server APIs.
1782
+ *
1783
+ * @returns {Promise<void>} The promise will be rejected if configure has not been called yet or there's an error
1784
+ * invalidating the virtual currencies cache.
1785
+ */
1786
+ Purchases.invalidateVirtualCurrenciesCache = function () {
1787
+ return __awaiter(this, void 0, void 0, function () {
1788
+ return __generator(this, function (_a) {
1789
+ switch (_a.label) {
1790
+ case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
1791
+ case 1:
1792
+ _a.sent();
1793
+ Purchases.logWarningIfPreviewAPIMode('invalidateVirtualCurrenciesCache');
1794
+ RNPurchases.invalidateVirtualCurrenciesCache();
1795
+ return [2 /*return*/];
1796
+ }
1797
+ });
1798
+ });
1799
+ };
1800
+ /**
1801
+ * The currently cached [PurchasesVirtualCurrencies] if one is available.
1802
+ * This value will remain null until virtual currencies have been fetched at
1803
+ * least once with [Purchases.getVirtualCurrencies] or an equivalent function.
1804
+ *
1805
+ * @returns {Promise<PurchasesVirtualCurrencies | null>} The currently cached virtual currencies for the current subscriber.
1806
+ * The promise will be rejected if configure has not been called yet or there's an error.
1807
+ */
1808
+ Purchases.getCachedVirtualCurrencies = function () {
1809
+ return __awaiter(this, void 0, void 0, function () {
1810
+ var result;
1811
+ return __generator(this, function (_a) {
1812
+ switch (_a.label) {
1813
+ case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
1814
+ case 1:
1815
+ _a.sent();
1816
+ Purchases.logWarningIfPreviewAPIMode('getCachedVirtualCurrencies');
1817
+ return [4 /*yield*/, RNPurchases.getCachedVirtualCurrencies()];
1818
+ case 2:
1819
+ result = _a.sent();
1820
+ return [2 /*return*/, result !== null && result !== void 0 ? result : null];
1821
+ }
1822
+ });
1823
+ });
1824
+ };
1757
1825
  /**
1758
1826
  * Check if configure has finished and Purchases has been configured.
1759
1827
  *
package/ios/RNPurchases.m CHANGED
@@ -562,6 +562,24 @@ RCT_EXPORT_METHOD(redeemWebPurchase:(NSString *)urlString
562
562
  reject:reject]];
563
563
  }
564
564
 
565
+ # pragma mark Virtual Currencies
566
+ RCT_EXPORT_METHOD(getVirtualCurrencies:
567
+ (RCTPromiseResolveBlock)resolve
568
+ reject:(RCTPromiseRejectBlock)reject) {
569
+ [RCCommonFunctionality getVirtualCurrenciesWithCompletion:[self getResponseCompletionBlockWithResolve:resolve
570
+ reject:reject]];
571
+ }
572
+
573
+ RCT_EXPORT_METHOD(invalidateVirtualCurrenciesCache) {
574
+ [RCCommonFunctionality invalidateVirtualCurrenciesCache];
575
+ }
576
+
577
+ RCT_EXPORT_METHOD(getCachedVirtualCurrencies:
578
+ (RCTPromiseResolveBlock)resolve
579
+ reject:(RCTPromiseRejectBlock)reject) {
580
+ resolve([RCCommonFunctionality getCachedVirtualCurrencies]);
581
+ }
582
+
565
583
  #pragma mark -
566
584
  #pragma mark PurchasesAreCompletedBy Helper Functions
567
585
  RCT_EXPORT_METHOD(recordPurchaseForProductID:(nonnull NSString *)productID
@@ -639,7 +657,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
639
657
  }
640
658
 
641
659
  - (NSString *)platformFlavorVersion {
642
- return @"9.0.0";
660
+ return @"9.1.0";
643
661
  }
644
662
 
645
663
  @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.0.0",
4
+ "version": "9.1.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",
@@ -111,6 +111,6 @@
111
111
  ]
112
112
  },
113
113
  "dependencies": {
114
- "@revenuecat/purchases-typescript-internal": "15.0.0"
114
+ "@revenuecat/purchases-typescript-internal": "16.0.2"
115
115
  }
116
116
  }