The Klaviyo React Native SDK Interface

This interface extends the KlaviyoEventAPI and KlaviyoProfileApi interfaces, providing a unified API for interacting with Klaviyo's event tracking and profile management features.

interface KlaviyoInterface {
    createEvent(event): void;
    createSubscription(subscription): void;
    getCurrentGeofences(callback): void;
    getEmail(callback): null | string;
    getExternalId(callback): null | string;
    getPhoneNumber(callback): null | string;
    getPushToken(callback): null | string;
    handleUniversalTrackingLink(trackingLink): boolean;
    initialize(apiKey): void;
    isLoggingEnabled(callback): void;
    registerAuthTokenProvider(provider): void;
    registerForInAppForms(configuration?): void;
    registerFormLifecycleHandler(handler): (() => void);
    registerGeofencing(): void;
    resetProfile(): void;
    setBadgeCount(count): void;
    setEmail(email): void;
    setExternalId(externalId): void;
    setLoggingEnabled(enabled): void;
    setPhoneNumber(phoneNumber): void;
    setProfile(profile): void;
    setProfileAttribute(propertyKey, value): void;
    setPushToken(token): void;
    unregisterAuthTokenProvider(): void;
    unregisterFromInAppForms(): void;
    unregisterGeofencing(): void;
}

Hierarchy (view full)

Methods

  • Create a new event to track a profile's activity.

    Parameters

    • event: Event

      The event to track

    Returns void

  • Subscribes the current profile to a Klaviyo list and records its consent.

    Set the profile's email and/or phone number before calling this. Push subscriptions are not created through this API — use setPushToken instead.

    Parameters

    Returns void

  • Internal

    Gets the currently monitored geofences from the native SDK.

    This is intended for demonstration and debugging purposes only. It may be subject to change or removal without notice.

    Parameters

    • callback: ((result) => void)
        • (result): void
        • Parameters

          Returns void

    Returns void

  • Retrieve a profile's email address.

    Parameters

    • callback: undefined | Function

      The callback function to handle the response

    Returns null | string

  • Retrieve a profile's external ID.

    Parameters

    • callback: undefined | Function

      The callback function to handle the response

    Returns null | string

  • Retrieve a profile's phone number.

    Parameters

    • callback: undefined | Function

      The callback function to handle the response

    Returns null | string

  • Get the push token for the current profile from the SDK

    Parameters

    • callback: undefined | Function

    Returns null | string

  • Resolves a Klaviyo tracking link to a Universal Link URL, then handles navigation to the resolved URL. The link must be a valid Klaviyo universal tracking link:

    • Uses HTTPS protocol
    • Path starts with '/u/'

    Parameters

    • trackingLink: null | string

      The tracking link to be handled

    Returns boolean

    • Whether the link was handled successfully
  • Initializes the Klaviyo SDK with the given API key.

    Parameters

    • apiKey: string

      Your public API key

    Returns void

  • Retrieve whether Klaviyo SDK logging is currently enabled.

    Parameters

    • callback: ((enabled) => void)

      The callback function to handle the response

        • (enabled): void
        • Parameters

          • enabled: boolean

          Returns void

    Returns void

  • Registers a provider that the native SDK invokes when it needs to acquire or refresh an authentication token (JWT) for the current end-user.

    The provider is an async function returning the current end-user's JWT, by whatever mechanism the host application uses to obtain a fresh token (e.g. calling its auth server or exchanging an OAuth refresh token). Read the current user fresh on each invocation rather than capturing identity at registration. Fetch a fresh JWT each time; do not cache tokens in the provider. The native SDK manages token caching and refresh.

    Register once and keep the provider registered across profile changes. On logout, clear the SDK profile with resetProfile(). Apply a timeout to every network call: the SDK does not time out or abort the provider itself. A provider that never settles blocks later token fetches until you register, unregister, or reset the profile.

    Calling this replaces any previously-registered provider. The call itself is synchronous (fire-and-forget) and returns void, consistent with other configuration methods such as KlaviyoProfileApi.setProfile and KlaviyoFormsApi.registerForInAppForms.

    Parameters

    • provider: AuthTokenProvider

      Async function that resolves with the current end-user's JWT.

    Returns void

  • Load in-app forms data and display a form to the user if applicable based on the forms configured in your Klaviyo account. Note [Klaviyo.initialize] must be called first

    Parameters

    • Optional configuration: FormConfiguration

      Duration (in seconds) of the period of user inactivity after which the user's app session is terminated and the forms session is ended. Defaults to 1 Hour.

    Returns void

  • Register a handler to receive form lifecycle events.

    Parameters

    Returns (() => void)

    A function to unsubscribe from lifecycle events

      • (): void
      • Returns void

  • Begin geofence monitoring Once proper permissions are granted from the user, we will fetch geofences configured for your account and begin reporting geofence transitions as analytics events.

    Returns void

  • Clear the current profile and set it to a new anonymous profile

    Returns void

  • Set the badge count for the app icon

    Parameters

    • count: number

    Returns void

  • Update a profile's email address.

    Parameters

    • email: string

      The email address to set

    Returns void

  • Update a profile's external ID.

    Parameters

    • externalId: string

      The external ID to set

    Returns void

  • Enable or disable all Klaviyo SDK logging at runtime.

    Logging is enabled by default. Disabling silences all log output from the native Klaviyo SDKs on both platforms; re-enabling restores the previous log verbosity.

    Note: on iOS this does not affect logging from KlaviyoSwiftExtension, which runs in a separate app extension process.

    Parameters

    • enabled: boolean

      Whether SDK logging should be enabled

    Returns void

  • Update a profile's phone number.

    Parameters

    • phoneNumber: string

      The phone number to set

    Returns void

  • Create and update properties about a profile without tracking an associated event.

    Parameters

    • profile: Profile

      The profile object to set

    Returns void

  • Update a profile's properties.

    Parameters

    • propertyKey: ProfilePropertyKey

      The property key to set

    • value: string

      The property value to set

    Returns void

  • Set the push token for the current profile

    Parameters

    • token: string

    Returns void

  • Detaches a previously-registered auth token provider to turn personalization off. This is not a logout; use resetProfile() to clear the SDK profile.

    Forwards to the native SDK, which clears the provider reference and tears down its own token state (cached token, scheduled refresh, and the native side of any in-flight fetch). A host provider() call that is already running is not aborted — it runs to completion and its late response is ignored. Re-registering after unregister works normally. A form that is already open keeps its token until it expires, whether you call resetProfile() or unregisterAuthTokenProvider().

    Returns void

  • Unregisters app from receiving in-app forms.

    Returns void

  • Stop monitoring geofences

    Returns void