UNPKG

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.

413 lines 14.9 kB
import { PLYPresentationViewBeta } from './PLYPresentationView'; interface Constants { logLevelDebug: number; logLevelWarn: number; logLevelInfo: number; logLevelError: number; productResultPurchased: number; productResultCancelled: number; productResultRestored: number; sourceAppStore: number; sourcePlayStore: number; sourceHuaweiAppGallery: number; sourceAmazonAppstore: number; sourceNone: number; firebaseAppInstanceId: number; airshipChannelId: number; airshipUserId: number; batchInstallationId: number; adjustId: number; appsflyerId: number; onesignalPlayerId: number; mixpanelDistinctId: number; clevertapId: number; sendinblueUserEmail: number; iterableUserId: number; iterableUserEmail: number; atInternetIdClient: number; amplitudeUserId: number; amplitudeDeviceId: number; mparticleUserId: number; customerIoUserId: number; customerIoUserEmail: number; branchUserDeveloperIdentity: number; moEngageUniqueId: number; batchCustomUserId: number; consumable: number; nonConsumable: number; autoRenewingSubscription: number; nonRenewingSubscription: number; unknown: number; runningModeTransactionOnly: number; runningModeObserver: number; runningModePaywallObserver: number; runningModeFull: number; presentationTypeNormal: number; presentationTypeFallback: number; presentationTypeDeactivated: number; presentationTypeClient: number; themeLight: number; themeDark: number; themeSystem: number; } export declare enum ProductResult { PRODUCT_RESULT_CANCELLED, PRODUCT_RESULT_PURCHASED, PRODUCT_RESULT_RESTORED } export declare enum LogLevels { DEBUG, INFO, WARNING, ERROR } export declare enum SubscriptionSource { APPLE_APP_STORE, GOOGLE_PLAY_STORE, HUAWEI_APP_GALLERY, AMAZON_APPSTORE } export declare enum Attributes { FIREBASE_APP_INSTANCE_ID, AIRSHIP_CHANNEL_ID, AIRSHIP_USER_ID, BATCH_INSTALLATION_ID, ADJUST_ID, APPSFLYER_ID, ONESIGNAL_PLAYER_ID, MIXPANEL_DISTINCT_ID, CLEVER_TAP_ID, SENDINBLUE_USER_EMAIL, ITERABLE_USER_ID, ITERABLE_USER_EMAIL, AT_INTERNET_ID_CLIENT, AMPLITUDE_USER_ID, AMPLITUDE_DEVICE_ID, MPARTICLE_USER_ID, CUSTOMER_IO_USER_ID, CUSTOMER_IO_USER_EMAIL, BRANCH_DEVELOPER_IDENTITY, MOENGAGE_UNIQUE_ID, BATCH_CUSTOM_USER_ID } export declare enum PlanType { PLAN_TYPE_CONSUMABLE, PLAN_TYPE_NON_CONSUMABLE, PLAN_TYPE_AUTO_RENEWING_SUBSCRIPTION, PLAN_TYPE_NON_RENEWING_SUBSCRIPTION, PLAN_TYPE_UNKNOWN } export declare enum RunningMode { TRANSACTION_ONLY, OBSERVER, PAYWALL_OBSERVER, FULL } export declare enum PLYThemeMode { LIGHT, DARK, SYSTEM } export declare enum PLYPaywallAction { CLOSE = "close", LOGIN = "login", NAVIGATE = "navigate", PURCHASE = "purchase", RESTORE = "restore", OPEN_PRESENTATION = "open_presentation", PROMO_CODE = "promo_code" } export declare enum PLYPresentationType { NORMAL, FALLBACK, DEACTIVATED, CLIENT } export type PLYPaywallInfo = { presentationId?: string; placementId?: string; contentId?: string; abTestId?: string; abTestVariantId?: string; }; export type PurchaselyPlan = { vendorId: string; productId: string; name: string; type: PlanType; amount: number; localizedAmount: string; currencyCode: string; currencySymbol: string; price: string; period: string; hasIntroductoryPrice: boolean; introPrice: string; introAmount: number; introDuration: string; introPeriod: string; hasFreeTrial: boolean; }; export type PurchaselyOffer = { vendorId?: string | null; storeOfferId?: string | null; }; export type PurchaselySubscriptionOffer = { subscriptionId: string; basePlanId?: string | null; offerToken?: string | null; offerId?: string | null; }; export type PurchaselyProduct = { name: string; vendorId: string; plans: PurchaselyPlan[]; }; export type PurchaselyPromotionalOfferSignature = { planVendorId: String; identifier: String; signature: String; nonce: any; keyIdentifier: String; timestamp: number; }; export type PurchaselyUserAttribute = { key: string; value: any; }; export type PurchaselySubscription = { purchaseToken: string; subscriptionSource: SubscriptionSource; nextRenewalDate: string; cancelledDate: string; plan: PurchaselyPlan; product: PurchaselyProduct; }; export type PresentPresentationResult = { result: ProductResult; plan: PurchaselyPlan; }; export type FetchPresentationResult = { presentation: PurchaselyPresentation; }; export type PaywallActionInterceptorResult = { info: PLYPaywallInfo; action: PLYPaywallAction; parameters: { url: String; title: String; plan: PurchaselyPlan; offer: PurchaselyOffer | null; subscriptionOffer: PurchaselySubscriptionOffer | null; presentation: String; }; }; type PurchaselyEventsNames = 'APP_INSTALLED' | 'APP_CONFIGURED' | 'APP_UPDATED' | 'APP_STARTED' | 'CANCELLATION_REASON_PUBLISHED' | 'IN_APP_PURCHASING' | 'IN_APP_PURCHASED' | 'IN_APP_RESTORED' | 'IN_APP_DEFERRED' | 'IN_APP_PURCHASE_FAILED' | 'IN_APP_NOT_AVAILABLE' | 'PURCHASE_CANCELLED_BY_APP' | 'CAROUSEL_SLIDE_SWIPED' | 'DEEPLINK_OPENED' | 'LINK_OPENED' | 'LOGIN_TAPPED' | 'PLAN_SELECTED' | 'PRESENTATION_VIEWED' | 'PRESENTATION_OPENED' | 'PRESENTATION_SELECTED' | 'PRESENTATION_LOADED' | 'PRESENTATION_CLOSED' | 'PROMO_CODE_TAPPED' | 'PURCHASE_CANCELLED' | 'PURCHASE_TAPPED' | 'RESTORE_TAPPED' | 'RECEIPT_CREATED' | 'RECEIPT_VALIDATED' | 'RECEIPT_FAILED' | 'RESTORE_STARTED' | 'RESTORE_SUCCEEDED' | 'RESTORE_FAILED' | 'SUBSCRIPTIONS_LIST_VIEWED' | 'SUBSCRIPTION_DETAILS_VIEWED' | 'SUBSCRIPTION_CANCEL_TAPPED' | 'SUBSCRIPTION_PLAN_TAPPED' | 'SUBSCRIPTIONS_TRANSFERRED' | 'USER_LOGGED_IN' | 'USER_LOGGED_OUT' | 'SUBSCRIPTION_CONTENT_USED'; type PurchaselyEventPropertyPlan = { type?: string; purchasely_plan_id?: string; store?: string; store_country?: string; store_product_id?: string; price_in_customer_currency?: number; customer_currency?: string; period?: string; duration?: number; intro_price_in_customer_currency?: number; intro_period?: string; intro_duration?: string; has_free_trial?: boolean; free_trial_period?: string; free_trial_duration?: number; discount_referent?: string; discount_percentage_comparison_to_referent?: string; discount_price_comparison_to_referent?: number; is_default: boolean; }; type PurchaselyEventPropertyCarousel = { selected_slide?: number; number_of_slides?: number; is_carousel_auto_playing: boolean; default_slide?: number; previous_slide?: number; }; type PurchaselyEventPropertySubscription = { plan?: String; product?: String; }; type PurchaselyEvent = { name: PurchaselyEventsNames; properties: PurchaselyEventProperties; }; type PurchaselyEventProperties = { sdk_version: string; event_name: PurchaselyEventsNames; event_created_at_ms: number; event_created_at: string; displayed_presentation?: string; user_id?: string; anonymous_user_id?: string; purchasable_plans?: PurchaselyEventPropertyPlan[]; deeplink_identifier?: string; source_identifier?: string; selected_plan?: string; previous_selected_plan?: string; selected_presentation?: string; previous_selected_presentation?: string; link_identifier?: string; carousels?: PurchaselyEventPropertyCarousel[]; language?: string; device?: string; os_version?: string; device_type?: string; error_message?: string; cancellation_reason_id?: string; cancellation_reason?: string; plan?: string; selected_product?: string; plan_change_type?: string; running_subscriptions?: PurchaselyEventPropertySubscription[]; }; export type PLYPresentationPlan = { planVendorId: string | null; storeProductId?: string | null; basePlanId?: string | null; offerId?: string | null; }; export type PLYPresentationMetadata = { [key: string]: string | number | boolean; }; export type PurchaselyPresentation = { id: string; placementId?: string | null; audienceId?: string | null; abTestId?: string | null; abTestVariantId?: string | null; language?: string | null; type?: PLYPresentationType | null; plans?: PLYPresentationPlan[] | null; metadata: PLYPresentationMetadata; }; interface StartParameters { apiKey: string; androidStores?: string[] | null; storeKit1: boolean; userId?: string | null; logLevel?: number | null; runningMode?: number | null; } declare function setUserAttributeWithDate(key: string, value: Date): void; type EventListenerCallback = (event: PurchaselyEvent) => void; type PurchaseListenerCallback = () => void; type DefaultPresentationResultCallback = (result: PresentPresentationResult) => void; type PaywallActionInterceptorCallback = (result: PaywallActionInterceptorResult) => void; interface FetchPresentationParameters { placementId?: string | null; presentationId?: string | null; contentId?: string | null; } interface PresentPresentationParameters { presentation?: PurchaselyPresentation | null; isFullscreen?: boolean; loadingBackgroundColor?: string | null; } interface PresentPresentationWithIdentifierParameters { presentationVendorId?: string | null; contentId?: string | null; isFullscreen?: boolean; loadingBackgroundColor?: string | null; } interface PresentPresentationPlacementParameters { placementVendorId?: string | null; contentId?: string | null; isFullscreen?: boolean; loadingBackgroundColor?: string | null; } interface PresentProductParameters { productVendorId?: string | null; presentationVendorId?: string | null; contentId?: string | null; isFullscreen?: boolean; loadingBackgroundColor?: string | null; } interface PresentPlanParameters { planVendorId?: string | null; presentationVendorId?: string | null; contentId?: string | null; isFullscreen?: boolean; loadingBackgroundColor?: string | null; } interface PurchasePlanParameters { planVendorId: string; offerId?: string | null; contentId?: string | null; } interface SignPromotionalOfferParameters { storeProductId: string; storeOfferId: string; } interface UserAttributesParameters { key: string; value?: number | null; } declare const Purchasely: { start: ({ apiKey, androidStores, storeKit1, userId, logLevel, runningMode, }: StartParameters) => Promise<boolean>; addEventListener: (callback: EventListenerCallback) => import("react-native").EmitterSubscription; removeEventListener: () => void; addPurchasedListener: (callback: PurchaseListenerCallback) => import("react-native").EmitterSubscription; removePurchasedListener: () => void; setDefaultPresentationResultCallback: (callback: DefaultPresentationResultCallback) => void; setPaywallActionInterceptorCallback: (callback: PaywallActionInterceptorCallback) => void; fetchPresentation: ({ placementId, presentationId, contentId, }: FetchPresentationParameters) => Promise<PurchaselyPresentation>; presentPresentation: ({ presentation, isFullscreen, loadingBackgroundColor, }: PresentPresentationParameters) => Promise<PresentPresentationResult>; presentPresentationWithIdentifier: ({ presentationVendorId, contentId, isFullscreen, loadingBackgroundColor, }: PresentPresentationWithIdentifierParameters) => Promise<PresentPresentationResult>; presentPresentationForPlacement: ({ placementVendorId, contentId, isFullscreen, loadingBackgroundColor, }: PresentPresentationPlacementParameters) => Promise<PresentPresentationResult>; presentProductWithIdentifier: ({ productVendorId, presentationVendorId, contentId, isFullscreen, loadingBackgroundColor, }: PresentProductParameters) => Promise<PresentPresentationResult>; presentPlanWithIdentifier: ({ planVendorId, presentationVendorId, contentId, isFullscreen, loadingBackgroundColor, }: PresentPlanParameters) => Promise<PresentPresentationResult>; purchaseWithPlanVendorId: ({ planVendorId, offerId, contentId, }: PurchasePlanParameters) => Promise<PurchaselyPlan>; setUserAttributeWithDate: typeof setUserAttributeWithDate; showPresentation: () => any; closePresentation: () => any; hidePresentation: () => any; signPromotionalOffer: ({ storeProductId, storeOfferId, }: SignPromotionalOfferParameters) => Promise<PurchaselyPromotionalOfferSignature>; incrementUserAttribute: ({ key, value, }: UserAttributesParameters) => void; decrementUserAttribute: ({ key, value, }: UserAttributesParameters) => void; getConstants(): Constants; close(): void; getAnonymousUserId(): Promise<string>; userLogin(userId: string): Promise<boolean>; userLogout(): void; setLogLevel(logLevel: LogLevels): void; readyToOpenDeeplink(ready: boolean): void; setAttribute(attribute: Attributes, value: string): void; allProducts(): Promise<PurchaselyProduct[]>; productWithIdentifier(vendorId: string): Promise<PurchaselyProduct>; planWithIdentifier(vendorId: string): Promise<PurchaselyPlan>; restoreAllProducts(): Promise<boolean>; silentRestoreAllProducts(): Promise<boolean>; userSubscriptions(): Promise<PurchaselySubscription[]>; userSubscriptionsHistory(): Promise<PurchaselySubscription[]>; presentSubscriptions(): void; isDeeplinkHandled(deeplink: string | null): Promise<boolean>; synchronize(): void; setDefaultPresentationResultHandler(): Promise<PresentPresentationResult>; setPaywallActionInterceptor(): Promise<PaywallActionInterceptorResult>; onProcessAction(processAction: boolean): void; setLanguage(language: string): void; userDidConsumeSubscriptionContent(): void; setUserAttributeWithString(key: string, value: string): void; setUserAttributeWithNumber(key: string, value: number): void; setUserAttributeWithBoolean(key: string, value: boolean): void; userAttributes(): Promise<PurchaselyUserAttribute>; userAttribute(key: string): Promise<any>; clearUserAttribute(key: string): void; clearUserAttributes(): void; clientPresentationDisplayed(presentation: PurchaselyPresentation): void; clientPresentationClosed(presentation: PurchaselyPresentation): void; isAnonymous(): Promise<boolean>; isEligibleForIntroOffer(planVendorId: String): Promise<boolean>; setThemeMode(theme: PLYThemeMode): void; }; export default Purchasely; export { PLYPresentationViewBeta }; //# sourceMappingURL=index.d.ts.map