react-native-adapty - v4.0.1
    Preparing search index...

    Interface FlowEventHandlers

    Hashmap of possible events to their callbacks

    interface FlowEventHandlers {
        onAnalytics: (
            name: string,
            params: Record<string, unknown>,
        ) => EventHandlerResult;
        onAndroidSystemBack: () => EventHandlerResult;
        onAppeared: () => EventHandlerResult;
        onCloseButtonPress: () => EventHandlerResult;
        onCustomAction: (actionId: string) => EventHandlerResult;
        onDisappeared: () => EventHandlerResult;
        onError: (error: AdaptyError) => EventHandlerResult;
        onLoadingProductsFailed: (error: AdaptyError) => EventHandlerResult;
        onObserverPurchaseInitiated: (
            product: AdaptyPaywallProduct,
            onStartPurchase: () => void,
            onFinishPurchase: () => void,
        ) => EventHandlerResult;
        onObserverRestoreInitiated: (
            onStartRestore: () => void,
            onFinishRestore: () => void,
        ) => EventHandlerResult;
        onProductSelected: (productId: string) => EventHandlerResult;
        onPurchaseCompleted: (
            purchaseResult: AdaptyPurchaseResult,
            product: AdaptyPaywallProduct,
        ) => EventHandlerResult;
        onPurchaseFailed: (
            error: AdaptyError,
            product: AdaptyPaywallProduct,
        ) => EventHandlerResult;
        onPurchaseStarted: (product: AdaptyPaywallProduct) => EventHandlerResult;
        onRequestAppReview: () => EventHandlerResult;
        onRequestPermission: (
            permission: AdaptyPermission,
            customArgs: Record<string, string>,
        ) => Promise<FlowPermissionResponse>;
        onRestoreCompleted: (profile: AdaptyProfile) => EventHandlerResult;
        onRestoreFailed: (error: AdaptyError) => EventHandlerResult;
        onRestoreStarted: () => EventHandlerResult;
        onUrlPress: (url: string, openIn: WebPresentation) => EventHandlerResult;
        onWebPaymentNavigationFinished: (
            product?: AdaptyPaywallProduct,
            error?: AdaptyError,
        ) => EventHandlerResult;
    }
    Index

    Properties

    onAnalytics: (
        name: string,
        params: Record<string, unknown>,
    ) => EventHandlerResult

    Called when the flow view reports an analytics event.

    This is a notification: the return value follows the standard close-on-true contract, but you normally keep the view open.

    Type Declaration

      • (name: string, params: Record<string, unknown>): EventHandlerResult
      • Parameters

        • name: string

          analytics event name

        • params: Record<string, unknown>

          arbitrary event parameters

        Returns EventHandlerResult

    onAndroidSystemBack: () => EventHandlerResult

    Called when a user navigates back on Android

    Return true to close the flow view. By default, this handler returns false, so the flow view stays open.

    false
    
    onAppeared: () => EventHandlerResult

    Called when the flow view appears

    If you return true, the flow view will be closed.

    false
    
    onCloseButtonPress: () => EventHandlerResult

    Called when a user taps the close button on the flow view

    If you return true, the flow view will be closed. We strongly recommend to return true in this case.

    true
    
    onCustomAction: (actionId: string) => EventHandlerResult
    onDisappeared: () => EventHandlerResult

    Called when the flow view disappears

    If you return true, the flow view will be closed.

    false
    
    onError: (error: AdaptyError) => EventHandlerResult

    Called when the flow view receives an error (e.g. it fails to render).

    If you return true from this callback, the flow view will be closed.

    Type Declaration

    onLoadingProductsFailed: (error: AdaptyError) => EventHandlerResult

    Called if a product list fails to load on a presented view, for example, if there is no internet connection

    If you return true from this callback, the flow view will be closed.

    Type Declaration

    onObserverPurchaseInitiated: (
        product: AdaptyPaywallProduct,
        onStartPurchase: () => void,
        onFinishPurchase: () => void,
    ) => EventHandlerResult

    Called in observer mode when the user taps the purchase button inside an Adapty-rendered flow view. Adapty does NOT make the purchase — your app performs it through its own purchase API. Drive the flow view's loading state with the two provided callbacks:

    • call onStartPurchase() right before you begin the purchase (shows the flow view's loading indicator);
    • call onFinishPurchase() once it settles, success or failure (hides it).

    The return value follows the standard close-on-true contract; you normally keep the view open (false) and dismiss it yourself after the purchase succeeds.

    Type Declaration

      • (
            product: AdaptyPaywallProduct,
            onStartPurchase: () => void,
            onFinishPurchase: () => void,
        ): EventHandlerResult
      • Parameters

        • product: AdaptyPaywallProduct

          product the user initiated the purchase for

        • onStartPurchase: () => void

          notify the flow view the purchase started

        • onFinishPurchase: () => void

          notify the flow view the purchase finished

        Returns EventHandlerResult

    Fires only when the SDK was activated in observer mode (activate(apiKey, { observerMode: true })). Without it, Adapty handles purchases itself and this event is never emitted.

    Adapty does not see the purchase you make, so after it succeeds you must report the transaction to Adapty yourself (e.g. via reportTransaction). The onStartPurchase/onFinishPurchase callbacks only drive the flow view's loading UI;

    onObserverRestoreInitiated: (
        onStartRestore: () => void,
        onFinishRestore: () => void,
    ) => EventHandlerResult

    Called in observer mode when the user taps the restore button inside an Adapty-rendered flow view. Adapty does NOT restore — your app performs it through its own API. Drive the flow view's loading state with the two provided callbacks (onStartRestore() / onFinishRestore()).

    Type Declaration

      • (onStartRestore: () => void, onFinishRestore: () => void): EventHandlerResult
      • Parameters

        • onStartRestore: () => void

          notify the flow view the restore started

        • onFinishRestore: () => void

          notify the flow view the restore finished

        Returns EventHandlerResult

    Fires only when the SDK was activated in observer mode (activate(apiKey, { observerMode: true })). Without it, Adapty handles restores itself and this event is never emitted.

    Report any transactions surfaced by the restore to Adapty yourself (e.g. via reportTransaction) so they flow into events and analytics. The onStartRestore/onFinishRestore callbacks only drive the flow view's loading UI; they do not report anything.

    onProductSelected: (productId: string) => EventHandlerResult

    Called when a user taps the product in the flow view

    If you return true from this callback, the flow view will be closed.

    onPurchaseCompleted: (
        purchaseResult: AdaptyPurchaseResult,
        product: AdaptyPaywallProduct,
    ) => EventHandlerResult

    Called when the purchase succeeds, the user cancels their purchase, or the purchase appears to be pending

    If you return true from this callback, the flow view will be closed. We strongly recommend returning purchaseResult.type !== 'user_cancelled' in this case.

    Type Declaration

    false
    
    onPurchaseFailed: (
        error: AdaptyError,
        product: AdaptyPaywallProduct,
    ) => EventHandlerResult

    Called if a purchase fails after a user taps the purchase button

    If you return true from this callback, the flow view will be closed.

    Type Declaration

    onPurchaseStarted: (product: AdaptyPaywallProduct) => EventHandlerResult

    Called when a user taps the purchase button in the flow view

    If you return true from this callback, the flow view will be closed.

    onRequestAppReview: () => EventHandlerResult

    Called when the flow view asks the host app to show the native app review prompt (e.g. SKStoreReviewController on iOS, In-App Review on Android).

    This is a notification: returning true would close the view, but for an app-review prompt you almost always want to keep it open.

    onRequestPermission: (
        permission: AdaptyPermission,
        customArgs: Record<string, string>,
    ) => Promise<FlowPermissionResponse>

    Called when the flow view asks the host app to request an OS-level permission (e.g. notifications, ATT). This is the only asynchronous handler: return a Promise that resolves with the resulting status.

    If you do not provide a handler, the SDK replies 'denied'.

    Type Declaration

    onRestoreCompleted: (profile: AdaptyProfile) => EventHandlerResult

    Called when a restore is completed

    If you return true from this callback, the flow view will be closed.

    Type Declaration

    false
    
    onRestoreFailed: (error: AdaptyError) => EventHandlerResult

    Called if a restore fails after a user taps the restore button

    If you return true from this callback, the flow view will be closed.

    Type Declaration

    onRestoreStarted: () => EventHandlerResult

    Called when a user taps the restore button in the flow view

    If you return true from this callback, the flow view will be closed.

    onUrlPress: (url: string, openIn: WebPresentation) => EventHandlerResult

    Called when the user taps a URL/link inside the paywall.

    Type Declaration

      • (url: string, openIn: WebPresentation): EventHandlerResult
      • Parameters

        • url: string

          URL to open

        • openIn: WebPresentation

          How the URL was configured to open in the dashboard: 'browser_in_app' — in-app browser (e.g. WKWebView / Custom Tabs) 'browser_out_app' (default) — external browser (e.g. Linking.openURL)

        Returns EventHandlerResult

    onWebPaymentNavigationFinished: (
        product?: AdaptyPaywallProduct,
        error?: AdaptyError,
    ) => EventHandlerResult