react-native-purchases
Version:
React Native in-app purchases and subscriptions made easy. Supports iOS and Android.
579 lines (578 loc) • 29.9 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.browserNativeModuleRNPurchases = void 0;
var purchases_typescript_internal_1 = require("@revenuecat/purchases-typescript-internal");
var purchases_js_hybrid_mappings_1 = require("@revenuecat/purchases-js-hybrid-mappings");
var typeGuards_1 = require("./typeGuards");
var environment_1 = require("../utils/environment");
var utils_1 = require("./utils");
var purchaseSimulatedPackageHelper_1 = require("./simulatedstore/purchaseSimulatedPackageHelper");
var packageVersion = '9.1.0';
/**
* Browser implementation of the native module. This will be used in the browser and Expo Go.
*/
exports.browserNativeModuleRNPurchases = {
setupPurchases: function (apiKey, appUserID, _purchasesAreCompletedBy, _userDefaultsSuiteName, _storeKitVersion, _useAmazon, _shouldShowInAppMessagesAutomatically, _entitlementVerificationMode, _pendingTransactionsForPrepaidPlansEnabled, _diagnosticsEnabled, _automaticDeviceIdentifierCollectionEnabled, _preferredUILocaleOverride) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
try {
purchases_js_hybrid_mappings_1.PurchasesCommon.configure({
apiKey: apiKey,
appUserId: appUserID || undefined,
flavor: 'react-native',
flavorVersion: packageVersion,
});
}
catch (error) {
console.error('Error configuring Purchases:', error);
throw error;
}
return [2 /*return*/];
});
}); },
setAllowSharingStoreAccount: function (_allowSharing) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setAllowSharingStoreAccount');
return [2 /*return*/];
});
}); },
setSimulatesAskToBuyInSandbox: function (_simulatesAskToBuyInSandbox) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setSimulatesAskToBuyInSandbox');
return [2 /*return*/];
});
}); },
getOfferings: function () { return __awaiter(void 0, void 0, void 0, function () {
var offerings;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getOfferings()];
case 1:
offerings = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(offerings, typeGuards_1.isPurchasesOfferings, 'PurchasesOfferings')];
}
});
}); },
getCurrentOfferingForPlacement: function (placementIdentifier) { return __awaiter(void 0, void 0, void 0, function () {
var offering;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getCurrentOfferingForPlacement(placementIdentifier)];
case 1:
offering = _a.sent();
return [2 /*return*/, offering ? (0, typeGuards_1.validateAndTransform)(offering, typeGuards_1.isPurchasesOffering, 'PurchasesOffering') : null];
}
});
}); },
syncAttributesAndOfferingsIfNeeded: function () { return __awaiter(void 0, void 0, void 0, function () {
var offerings;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getOfferings()];
case 1:
offerings = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(offerings, typeGuards_1.isPurchasesOfferings, 'PurchasesOfferings')];
}
});
}); },
getProductInfo: function (_productIdentifiers, _type) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('getProductInfo');
return [2 /*return*/];
});
}); },
restorePurchases: function () { return __awaiter(void 0, void 0, void 0, function () {
var customerInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getCustomerInfo()];
case 1:
customerInfo = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(customerInfo, typeGuards_1.isCustomerInfo, 'CustomerInfo')];
}
});
}); },
getAppUserID: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.ensurePurchasesConfigured)();
return [2 /*return*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getAppUserId()];
});
}); },
getStorefront: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('getStorefront');
return [2 /*return*/];
});
}); },
setDebugLogsEnabled: function (_enabled) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setDebugLogsEnabled');
return [2 /*return*/];
});
}); },
setLogLevel: function (level) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
purchases_js_hybrid_mappings_1.PurchasesCommon.setLogLevel(level);
return [2 /*return*/];
});
}); },
setLogHandler: function (_handler) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setLogHandler');
return [2 /*return*/];
});
}); },
getCustomerInfo: function () { return __awaiter(void 0, void 0, void 0, function () {
var customerInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getCustomerInfo()];
case 1:
customerInfo = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(customerInfo, typeGuards_1.isCustomerInfo, 'CustomerInfo')];
}
});
}); },
logIn: function (appUserID) { return __awaiter(void 0, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().logIn(appUserID)];
case 1:
result = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(result, typeGuards_1.isLogInResult, 'LogInResult')];
}
});
}); },
logOut: function () { return __awaiter(void 0, void 0, void 0, function () {
var customerInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().logOut()];
case 1:
customerInfo = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(customerInfo, typeGuards_1.isCustomerInfo, 'CustomerInfo')];
}
});
}); },
syncPurchases: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('syncPurchases');
return [2 /*return*/];
});
}); },
syncAmazonPurchase: function (_productID, _receiptID, _amazonUserID, _isoCurrencyCode, _price) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('syncAmazonPurchase');
return [2 /*return*/];
});
}); },
syncObserverModeAmazonPurchase: function (_productID, _receiptID, _amazonUserID, _isoCurrencyCode, _price) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('syncObserverModeAmazonPurchase');
return [2 /*return*/];
});
}); },
recordPurchaseForProductID: function (_productID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('recordPurchaseForProductID');
return [2 /*return*/];
});
}); },
enableAdServicesAttributionTokenCollection: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('enableAdServicesAttributionTokenCollection');
return [2 /*return*/];
});
}); },
purchaseProduct: function (_productIdentifier, _googleProductChangeInfo, _type, _discountTimestamp, _googleInfo, _presentedOfferingContext) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('purchaseProduct');
return [2 /*return*/];
});
}); },
purchasePackage: function (packageIdentifier, presentedOfferingContext, _googleProductChangeInfo, _discountTimestamp, _googleInfo) { return __awaiter(void 0, void 0, void 0, function () {
var purchaseResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
if (!(0, environment_1.isExpoGo)()) return [3 /*break*/, 2];
return [4 /*yield*/, (0, purchaseSimulatedPackageHelper_1.purchaseSimulatedPackage)(packageIdentifier, presentedOfferingContext)];
case 1: return [2 /*return*/, _a.sent()];
case 2: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().purchasePackage({
packageIdentifier: packageIdentifier,
presentedOfferingContext: presentedOfferingContext,
})];
case 3:
purchaseResult = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(purchaseResult, typeGuards_1.isMakePurchaseResult, 'MakePurchaseResult')];
}
});
}); },
purchaseSubscriptionOption: function (_productIdentifier, _optionIdentifier, _upgradeInfo, _discountTimestamp, _googleInfo, _presentedOfferingContext) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('purchaseSubscriptionOption');
return [2 /*return*/];
});
}); },
isAnonymous: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.ensurePurchasesConfigured)();
return [2 /*return*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().isAnonymous()];
});
}); },
makeDeferredPurchase: function (_callbackID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('makeDeferredPurchase');
return [2 /*return*/];
});
}); },
checkTrialOrIntroductoryPriceEligibility: function (productIDs) { return __awaiter(void 0, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
result = {};
productIDs.forEach(function (productId) {
result[productId] = purchases_typescript_internal_1.INTRO_ELIGIBILITY_STATUS.INTRO_ELIGIBILITY_STATUS_UNKNOWN;
});
return [2 /*return*/, result];
});
}); },
getPromotionalOffer: function (_productIdentifier, _discount) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('getPromotionalOffer');
return [2 /*return*/];
});
}); },
eligibleWinBackOffersForProductIdentifier: function (_productID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('eligibleWinBackOffersForProductIdentifier');
return [2 /*return*/];
});
}); },
purchaseProductWithWinBackOffer: function (_productID, _winBackOfferID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('purchaseProductWithWinBackOffer');
return [2 /*return*/];
});
}); },
purchasePackageWithWinBackOffer: function (_packageID, _winBackOfferID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('purchasePackageWithWinBackOffer');
return [2 /*return*/];
});
}); },
invalidateCustomerInfoCache: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('invalidateCustomerInfoCache');
return [2 /*return*/];
});
}); },
presentCodeRedemptionSheet: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('presentCodeRedemptionSheet');
return [2 /*return*/];
});
}); },
setAttributes: function (attributes) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().setAttributes(attributes)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); },
setEmail: function (email) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().setEmail(email)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); },
setPhoneNumber: function (phoneNumber) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().setPhoneNumber(phoneNumber)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); },
setDisplayName: function (displayName) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().setDisplayName(displayName)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); },
setPushToken: function (_pushToken) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setPushToken');
return [2 /*return*/];
});
}); },
setProxyURLString: function (proxyURLString) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
purchases_js_hybrid_mappings_1.PurchasesCommon.setProxyUrl(proxyURLString);
return [2 /*return*/];
});
}); },
collectDeviceIdentifiers: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('collectDeviceIdentifiers');
return [2 /*return*/];
});
}); },
setAdjustID: function (_adjustID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setAdjustID');
return [2 /*return*/];
});
}); },
setAppsflyerID: function (_appsflyerID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setAppsflyerID');
return [2 /*return*/];
});
}); },
setFBAnonymousID: function (_fbAnonymousID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setFBAnonymousID');
return [2 /*return*/];
});
}); },
setMparticleID: function (_mparticleID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setMparticleID');
return [2 /*return*/];
});
}); },
setCleverTapID: function (_cleverTapID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setCleverTapID');
return [2 /*return*/];
});
}); },
setMixpanelDistinctID: function (_mixpanelDistinctID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setMixpanelDistinctID');
return [2 /*return*/];
});
}); },
setFirebaseAppInstanceID: function (_firebaseAppInstanceID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setFirebaseAppInstanceID');
return [2 /*return*/];
});
}); },
setTenjinAnalyticsInstallationID: function (_tenjinAnalyticsInstallationID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setTenjinAnalyticsInstallationID');
return [2 /*return*/];
});
}); },
setKochavaDeviceID: function (_kochavaDeviceID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setKochavaDeviceID');
return [2 /*return*/];
});
}); },
setOnesignalID: function (_onesignalID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setOnesignalID');
return [2 /*return*/];
});
}); },
setAirshipChannelID: function (_airshipChannelID) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setAirshipChannelID');
return [2 /*return*/];
});
}); },
setMediaSource: function (_mediaSource) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setMediaSource');
return [2 /*return*/];
});
}); },
setMediaCampaign: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setMediaCampaign');
return [2 /*return*/];
});
}); },
setCampaign: function (_campaign) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setCampaign');
return [2 /*return*/];
});
}); },
setAdGroup: function (_adGroup) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setAdGroup');
return [2 /*return*/];
});
}); },
setAd: function (_ad) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setAd');
return [2 /*return*/];
});
}); },
setKeyword: function (_keyword) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setKeyword');
return [2 /*return*/];
});
}); },
setCreative: function (_creative) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('setCreative');
return [2 /*return*/];
});
}); },
overridePreferredLocale: function (_locale) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('overridePreferredLocale');
return [2 /*return*/];
});
}); },
canMakePayments: function (_features) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, true];
});
}); },
beginRefundRequestForActiveEntitlement: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('beginRefundRequestForActiveEntitlement');
return [2 /*return*/];
});
}); },
beginRefundRequestForEntitlementId: function (_entitlementIdentifier) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('beginRefundRequestForEntitlementId');
return [2 /*return*/];
});
}); },
beginRefundRequestForProductId: function (_productIdentifier) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('beginRefundRequestForProductId');
return [2 /*return*/];
});
}); },
showManageSubscriptions: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('showManageSubscriptions');
return [2 /*return*/];
});
}); },
showInAppMessages: function (_messageTypes) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('showInAppMessages');
return [2 /*return*/];
});
}); },
isWebPurchaseRedemptionURL: function (_urlString) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('isWebPurchaseRedemptionURL');
return [2 /*return*/];
});
}); },
isConfigured: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, purchases_js_hybrid_mappings_1.PurchasesCommon.isConfigured()];
});
}); },
redeemWebPurchase: function (_urlString) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.methodNotSupportedOnWeb)('redeemWebPurchase');
return [2 /*return*/];
});
}); },
getVirtualCurrencies: function () { return __awaiter(void 0, void 0, void 0, function () {
var virtualCurrencies;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
(0, utils_1.ensurePurchasesConfigured)();
return [4 /*yield*/, purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getVirtualCurrencies()];
case 1:
virtualCurrencies = _a.sent();
return [2 /*return*/, (0, typeGuards_1.validateAndTransform)(virtualCurrencies, typeGuards_1.isPurchasesVirtualCurrencies, 'PurchasesVirtualCurrencies')];
}
});
}); },
invalidateVirtualCurrenciesCache: function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
(0, utils_1.ensurePurchasesConfigured)();
purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().invalidateVirtualCurrenciesCache();
return [2 /*return*/];
});
}); },
getCachedVirtualCurrencies: function () { return __awaiter(void 0, void 0, void 0, function () {
var cachedVirtualCurrencies;
return __generator(this, function (_a) {
(0, utils_1.ensurePurchasesConfigured)();
cachedVirtualCurrencies = purchases_js_hybrid_mappings_1.PurchasesCommon.getInstance().getCachedVirtualCurrencies();
return [2 /*return*/, cachedVirtualCurrencies ? (0, typeGuards_1.validateAndTransform)(cachedVirtualCurrencies, typeGuards_1.isPurchasesVirtualCurrencies, 'PurchasesVirtualCurrencies') : null];
});
}); },
};