react-native-purchasely
Version:
Purchasely is a solution to ease the integration and boost your In-App Purchase & Subscriptions on the App Store, Google Play Store and Huawei App Gallery.
259 lines (257 loc) • 12.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PLYPresentationType = exports.PLYPaywallAction = exports.LogLevels = exports.Attributes = void 0;
Object.defineProperty(exports, "PLYPresentationViewBeta", {
enumerable: true,
get: function () {
return _PLYPresentationView.PLYPresentationViewBeta;
}
});
exports.default = exports.SubscriptionSource = exports.RunningMode = exports.ProductResult = exports.PlanType = exports.PLYThemeMode = void 0;
var _reactNative = require("react-native");
var _PLYPresentationView = require("./PLYPresentationView");
//import { PurchaselyView } from './PurchaselyViewManager';
const purchaselyVersion = '4.5.0';
const constants = _reactNative.NativeModules.Purchasely.getConstants();
let ProductResult = exports.ProductResult = function (ProductResult) {
ProductResult[ProductResult["PRODUCT_RESULT_CANCELLED"] = constants.productResultCancelled] = "PRODUCT_RESULT_CANCELLED";
ProductResult[ProductResult["PRODUCT_RESULT_PURCHASED"] = constants.productResultPurchased] = "PRODUCT_RESULT_PURCHASED";
ProductResult[ProductResult["PRODUCT_RESULT_RESTORED"] = constants.productResultRestored] = "PRODUCT_RESULT_RESTORED";
return ProductResult;
}({});
let LogLevels = exports.LogLevels = function (LogLevels) {
LogLevels[LogLevels["DEBUG"] = constants.logLevelDebug] = "DEBUG";
LogLevels[LogLevels["INFO"] = constants.logLevelInfo] = "INFO";
LogLevels[LogLevels["WARNING"] = constants.logLevelWarn] = "WARNING";
LogLevels[LogLevels["ERROR"] = constants.logLevelError] = "ERROR";
return LogLevels;
}({});
let SubscriptionSource = exports.SubscriptionSource = function (SubscriptionSource) {
SubscriptionSource[SubscriptionSource["APPLE_APP_STORE"] = constants.sourceAppStore] = "APPLE_APP_STORE";
SubscriptionSource[SubscriptionSource["GOOGLE_PLAY_STORE"] = constants.sourcePlayStore] = "GOOGLE_PLAY_STORE";
SubscriptionSource[SubscriptionSource["HUAWEI_APP_GALLERY"] = constants.sourceHuaweiAppGallery] = "HUAWEI_APP_GALLERY";
SubscriptionSource[SubscriptionSource["AMAZON_APPSTORE"] = constants.sourceAmazonAppstore] = "AMAZON_APPSTORE";
return SubscriptionSource;
}({});
let Attributes = exports.Attributes = function (Attributes) {
Attributes[Attributes["FIREBASE_APP_INSTANCE_ID"] = constants.firebaseAppInstanceId] = "FIREBASE_APP_INSTANCE_ID";
Attributes[Attributes["AIRSHIP_CHANNEL_ID"] = constants.airshipChannelId] = "AIRSHIP_CHANNEL_ID";
Attributes[Attributes["AIRSHIP_USER_ID"] = constants.airshipUserId] = "AIRSHIP_USER_ID";
Attributes[Attributes["BATCH_INSTALLATION_ID"] = constants.batchInstallationId] = "BATCH_INSTALLATION_ID";
Attributes[Attributes["ADJUST_ID"] = constants.adjustId] = "ADJUST_ID";
Attributes[Attributes["APPSFLYER_ID"] = constants.appsflyerId] = "APPSFLYER_ID";
Attributes[Attributes["ONESIGNAL_PLAYER_ID"] = constants.onesignalPlayerId] = "ONESIGNAL_PLAYER_ID";
Attributes[Attributes["MIXPANEL_DISTINCT_ID"] = constants.mixpanelDistinctId] = "MIXPANEL_DISTINCT_ID";
Attributes[Attributes["CLEVER_TAP_ID"] = constants.clevertapId] = "CLEVER_TAP_ID";
Attributes[Attributes["SENDINBLUE_USER_EMAIL"] = constants.sendinblueUserEmail] = "SENDINBLUE_USER_EMAIL";
Attributes[Attributes["ITERABLE_USER_ID"] = constants.iterableUserId] = "ITERABLE_USER_ID";
Attributes[Attributes["ITERABLE_USER_EMAIL"] = constants.iterableUserEmail] = "ITERABLE_USER_EMAIL";
Attributes[Attributes["AT_INTERNET_ID_CLIENT"] = constants.atInternetIdClient] = "AT_INTERNET_ID_CLIENT";
Attributes[Attributes["AMPLITUDE_USER_ID"] = constants.amplitudeUserId] = "AMPLITUDE_USER_ID";
Attributes[Attributes["AMPLITUDE_DEVICE_ID"] = constants.amplitudeDeviceId] = "AMPLITUDE_DEVICE_ID";
Attributes[Attributes["MPARTICLE_USER_ID"] = constants.mparticleUserId] = "MPARTICLE_USER_ID";
Attributes[Attributes["CUSTOMER_IO_USER_ID"] = constants.customerIoUserId] = "CUSTOMER_IO_USER_ID";
Attributes[Attributes["CUSTOMER_IO_USER_EMAIL"] = constants.customerIoUserEmail] = "CUSTOMER_IO_USER_EMAIL";
Attributes[Attributes["BRANCH_DEVELOPER_IDENTITY"] = constants.branchUserDeveloperIdentity] = "BRANCH_DEVELOPER_IDENTITY";
Attributes[Attributes["MOENGAGE_UNIQUE_ID"] = constants.moEngageUniqueId] = "MOENGAGE_UNIQUE_ID";
Attributes[Attributes["BATCH_CUSTOM_USER_ID"] = constants.batchCustomUserId] = "BATCH_CUSTOM_USER_ID";
return Attributes;
}({});
let PlanType = exports.PlanType = function (PlanType) {
PlanType[PlanType["PLAN_TYPE_CONSUMABLE"] = constants.consumable] = "PLAN_TYPE_CONSUMABLE";
PlanType[PlanType["PLAN_TYPE_NON_CONSUMABLE"] = constants.nonConsumable] = "PLAN_TYPE_NON_CONSUMABLE";
PlanType[PlanType["PLAN_TYPE_AUTO_RENEWING_SUBSCRIPTION"] = constants.autoRenewingSubscription] = "PLAN_TYPE_AUTO_RENEWING_SUBSCRIPTION";
PlanType[PlanType["PLAN_TYPE_NON_RENEWING_SUBSCRIPTION"] = constants.nonRenewingSubscription] = "PLAN_TYPE_NON_RENEWING_SUBSCRIPTION";
PlanType[PlanType["PLAN_TYPE_UNKNOWN"] = constants.unknown] = "PLAN_TYPE_UNKNOWN";
return PlanType;
}({});
let RunningMode = exports.RunningMode = function (RunningMode) {
RunningMode[RunningMode["TRANSACTION_ONLY"] = constants.runningModeTransactionOnly] = "TRANSACTION_ONLY";
RunningMode[RunningMode["OBSERVER"] = constants.runningModeObserver] = "OBSERVER";
RunningMode[RunningMode["PAYWALL_OBSERVER"] = constants.runningModePaywallObserver] = "PAYWALL_OBSERVER";
RunningMode[RunningMode["FULL"] = constants.runningModeFull] = "FULL";
return RunningMode;
}({});
let PLYThemeMode = exports.PLYThemeMode = function (PLYThemeMode) {
PLYThemeMode[PLYThemeMode["LIGHT"] = constants.themeLight] = "LIGHT";
PLYThemeMode[PLYThemeMode["DARK"] = constants.themeDark] = "DARK";
PLYThemeMode[PLYThemeMode["SYSTEM"] = constants.themeSystem] = "SYSTEM";
return PLYThemeMode;
}({});
let PLYPaywallAction = exports.PLYPaywallAction = /*#__PURE__*/function (PLYPaywallAction) {
PLYPaywallAction["CLOSE"] = "close";
PLYPaywallAction["LOGIN"] = "login";
PLYPaywallAction["NAVIGATE"] = "navigate";
PLYPaywallAction["PURCHASE"] = "purchase";
PLYPaywallAction["RESTORE"] = "restore";
PLYPaywallAction["OPEN_PRESENTATION"] = "open_presentation";
PLYPaywallAction["PROMO_CODE"] = "promo_code";
return PLYPaywallAction;
}({});
let PLYPresentationType = exports.PLYPresentationType = function (PLYPresentationType) {
PLYPresentationType[PLYPresentationType["NORMAL"] = constants.presentationTypeNormal] = "NORMAL";
PLYPresentationType[PLYPresentationType["FALLBACK"] = constants.presentationTypeFallback] = "FALLBACK";
PLYPresentationType[PLYPresentationType["DEACTIVATED"] = constants.presentationTypeDeactivated] = "DEACTIVATED";
PLYPresentationType[PLYPresentationType["CLIENT"] = constants.presentationTypeClient] = "CLIENT";
return PLYPresentationType;
}({});
const RNPurchasely = _reactNative.NativeModules.Purchasely;
const PurchaselyEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Purchasely);
const start = ({
apiKey,
androidStores = ['Google'],
storeKit1,
userId = null,
logLevel = LogLevels.ERROR,
runningMode = RunningMode.FULL
}) => {
return _reactNative.NativeModules.Purchasely.start(apiKey, androidStores, storeKit1, userId, logLevel, runningMode, purchaselyVersion);
};
function setUserAttributeWithDate(key, value) {
const dateAsString = value.toISOString();
return _reactNative.NativeModules.Purchasely.setUserAttributeWithDate(key, dateAsString);
}
const addEventListener = callback => {
return PurchaselyEventEmitter.addListener('PURCHASELY_EVENTS', callback);
};
const removeEventListener = () => {
return PurchaselyEventEmitter.removeAllListeners('PURCHASELY_EVENTS');
};
const addPurchasedListener = callback => {
return PurchaselyEventEmitter.addListener('PURCHASE_LISTENER', callback);
};
const removePurchasedListener = () => {
return PurchaselyEventEmitter.removeAllListeners('PURCHASE_LISTENER');
};
const setDefaultPresentationResultCallback = callback => {
Purchasely.setDefaultPresentationResultHandler().then(result => {
setDefaultPresentationResultCallback(callback);
try {
callback(result);
} catch (e) {
console.warn('[Purchasely] Error with callback for default presentation result', e);
}
});
};
const setPaywallActionInterceptorCallback = callback => {
Purchasely.setPaywallActionInterceptor().then(result => {
setPaywallActionInterceptorCallback(callback);
try {
callback(result);
} catch (e) {
console.warn('[Purchasely] Error with paywall interceptor callback', e);
}
});
};
const fetchPresentation = ({
placementId = null,
presentationId = null,
contentId = null
}) => {
return _reactNative.NativeModules.Purchasely.fetchPresentation(placementId, presentationId, contentId);
};
const presentPresentation = ({
presentation = null,
isFullscreen = false,
loadingBackgroundColor = null
}) => {
return _reactNative.NativeModules.Purchasely.presentPresentation(presentation, isFullscreen, loadingBackgroundColor);
};
const presentPresentationWithIdentifier = ({
presentationVendorId = null,
contentId = null,
isFullscreen = false,
loadingBackgroundColor = null
}) => {
return _reactNative.NativeModules.Purchasely.presentPresentationWithIdentifier(presentationVendorId, contentId, isFullscreen, loadingBackgroundColor);
};
const presentPresentationForPlacement = ({
placementVendorId = null,
contentId = null,
isFullscreen = false,
loadingBackgroundColor = null
}) => {
return _reactNative.NativeModules.Purchasely.presentPresentationForPlacement(placementVendorId, contentId, isFullscreen, loadingBackgroundColor);
};
const presentProductWithIdentifier = ({
productVendorId = null,
presentationVendorId = null,
contentId = null,
isFullscreen = false,
loadingBackgroundColor = null
}) => {
return _reactNative.NativeModules.Purchasely.presentProductWithIdentifier(productVendorId, presentationVendorId, contentId, isFullscreen, loadingBackgroundColor);
};
const presentPlanWithIdentifier = ({
planVendorId = null,
presentationVendorId = null,
contentId = null,
isFullscreen = false,
loadingBackgroundColor = null
}) => {
return _reactNative.NativeModules.Purchasely.presentPlanWithIdentifier(planVendorId, presentationVendorId, contentId, isFullscreen, loadingBackgroundColor);
};
const purchaseWithPlanVendorId = ({
planVendorId,
offerId = null,
contentId = null
}) => {
return _reactNative.NativeModules.Purchasely.purchaseWithPlanVendorId(planVendorId, offerId, contentId);
};
const signPromotionalOffer = ({
storeProductId,
storeOfferId
}) => {
return _reactNative.NativeModules.Purchasely.signPromotionalOffer(storeProductId, storeOfferId);
};
const closePresentation = () => {
return _reactNative.NativeModules.Purchasely.closePresentation();
};
const hidePresentation = () => {
return _reactNative.NativeModules.Purchasely.hidePresentation();
};
const showPresentation = () => {
return _reactNative.NativeModules.Purchasely.showPresentation();
};
const incrementUserAttribute = ({
key,
value
}) => {
const nonNullValue = value ?? 1;
return _reactNative.NativeModules.Purchasely.incrementUserAttribute(key, nonNullValue);
};
const decrementUserAttribute = ({
key,
value
}) => {
const nonNullValue = value ?? 1;
return _reactNative.NativeModules.Purchasely.decrementUserAttribute(key, nonNullValue);
};
const Purchasely = {
...RNPurchasely,
start,
addEventListener,
removeEventListener,
addPurchasedListener,
removePurchasedListener,
setDefaultPresentationResultCallback,
setPaywallActionInterceptorCallback,
fetchPresentation,
presentPresentation,
presentPresentationWithIdentifier,
presentPresentationForPlacement,
presentProductWithIdentifier,
presentPlanWithIdentifier,
purchaseWithPlanVendorId,
setUserAttributeWithDate,
showPresentation,
closePresentation,
hidePresentation,
signPromotionalOffer,
incrementUserAttribute,
decrementUserAttribute
};
var _default = exports.default = Purchasely; //export { PurchaselyView };
//# sourceMappingURL=index.js.map
;