import { NativeEventEmitter, EmitterSubscription } from 'react-native'; import { Variables, Variable, Parameters, LocationAccuracyType, ActionContextData, SecuredVars, MigrationConfig } from './leanplum-types'; /** * Leanplum React Native Sdk */ declare class LeanplumSdkModule extends NativeEventEmitter { /** NativeModule of react-native. */ private readonly nativeModule; /** Flag showing whether CleverTap instance is created */ private cleverTapReady; /** Listener name used to notify when CleverTap instance is created. */ private static readonly CLEVERTAP_READY_INTERNAL_EVENT; /** Default value for the name of the Purchase event. */ private static readonly PURCHASE_EVENT_NAME; /** Listener name used when the variables receive new values from the server. */ private static readonly ON_VARIABLES_CHANGE_LISTENER; /** Listener name used when no more file downloads are pending. */ private static readonly ON_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING; /** Listener name used once when no more file downloads are pending. */ private static readonly ONCE_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING; /** Listener name used when a message is displayed. */ private static readonly ON_MESSAGE_DISPLAYED; /** Listener name used when a message is dismissed. */ private static readonly ON_MESSAGE_DISMISSED; /** Listener name used when message action is executed. */ private static readonly ON_MESSAGE_ACTION; /** Listener name used when CleverTap instance is initialized. */ private static readonly ON_CT_INSTANCE; /** * Creates an instance of LeanplumSdkModule. * @param nativeModule the NativeModule of react-native */ constructor(nativeModule: any); private registerCleverTapInstanceListener; /** * Registers a callback to be invoked once CleverTap instance is created using Leanplum data. If * CleverTap instance is already created, the callback will be invoked immediately. * * @param callback Callback to be invoked once CleverTap instance is ready. * * @returns Returns null if CleveTap is already created or EmitterSubscription object. You can use * the EmitterSubscription to cancel the subscription. */ onCleverTapReady(callback: () => void): (EmitterSubscription | null); /** Throw an exception with unsupported platform message. */ throwUnsupportedPlatform(): void; /** * Must call before issuing any calls to the API, including start. * * @param appVersion Your app version. */ setAppVersion(appVersion: string): void; /** * Must call either this or [[LeanplumSdkModule.setAppIdForProductionMode]] before issuing any calls to * the API, including start. * * @param appId Your app ID. * @param accessKey Your development key. */ setAppIdForDevelopmentMode(appId: string, accessKey: string): void; /** * Must call either this or [[LeanplumSdkModule.setAppIdForDevelopmentMode]] before issuing any calls * to the API, including start. * * @param appId Your app ID. * @param accessKey Your production key. */ setAppIdForProductionMode(appId: string, accessKey: string): void; /** * Sets a custom device ID. * @param id. */ setDeviceId(id: string): void; /** * Updates the user ID. * @param id. */ setUserId(id: string): void; /** * Adds or modifies user attributes. * @param attributes. */ setUserAttributes(attributes: Parameters): void; /** * Returns the userId in the current Leanplum session. This should only be called after [[LeanplumSdkModule.start]]. * @returns userId in the current Leanplum session. */ userId(): Promise; /** * Gets the deviceId in the current Leanplum session. This should only be called after [[LeanplumSdkModule.start]]. * @returns deviceId in the current Leanplum session. */ deviceId(): Promise; /** * Define/Set new variables with default values. This should only be called after [[LeanplumSdkModule.start]]. * @param variables with default values. */ setVariables(variables: Variables): void; /** * Optional. Sets the API server. The API path is of the form http[s]://hostname/apiPath * * @param hostName The name of the API host, such as www.leanplum.com * @param apiPath The name of the API servlet, such as api * @param ssl Whether to use SSL */ setApiConnectionSettings(hostName: string, apiPath: string, ssl: boolean): void; /** * Optional. Sets the socket server path for Development mode. Path is of the form hostName:port * * @param hostName The host name of the socket server. * @param port The port to connect to. */ setSocketConnectionSettings(hostName: string, port: number): void; /** * Get value for specific variable previously defined. * * @param name of the variable. * @returns a Promise with the variable value. */ getVariable(name: String): Promise; /** * Get the values for all the variables previously defined. * * @returns a Promise with the values of the variables. */ getVariables(): Promise; /** * Define/Set asset with the default filename value. This should only be called after [[LeanplumSdkModule.start]]. * * @param name of the variable. * @param defaultValue default filename of the asset. * @param onAssetReadyCallback callback with the path of the asset as a parameter that will be invoked when the asset is already downloaded. */ setVariableAsset(name: string, filename: string, onAssetReadyCallback: (path: string) => void): void; /** * Gets variable asset path previously defined. * @param name. * @returns variable asset. */ getVariableAsset(name: string): Promise; /** * Add callback when start finishes. This should only be called after [[LeanplumSdkModule.start]]. * * @param callback to be invoked with a boolean value as parameter when start finishes. */ onStartResponse(callback: (success: boolean) => void): void; /** * Register a callback when a specific variable receive new value from the server. * * @param name of the variable previously defined. * @param callback to be invoked with the value of the variable as parameter. */ onValueChanged(variableName: string, callback: (value: Variable) => void): void; /** * Register a callback when the variables receive new values from the server. * * @param callback to be invoked with the values of the variables as parameter. */ onVariablesChanged(callback: (value: Variables) => void): void; /** * Call this when your application starts. This will initiate a call to Leanplum's servers to get * the values of the variables used in your app. */ start(): void; /** * Returns whether or not Leanplum has finished starting. * * @returns a Promise with the value of hasStarted. */ hasStarted(): Promise; /** * Forces content to update from the server. If variables have changed, the appropriate callbacks * will fire. Use sparingly as if the app is updated, you'll have to deal with potentially * inconsistent state or user experience. */ forceContentUpdate(): void; /** * Logs a particular event in your application. The string can be any value of your choosing, and * will show up in the dashboard. * @param event Name of the event. * @param [params] Key-value pairs with metrics or data associated with the event. Parameters can be * strings or numbers. You can use up to 200 different parameter names in your app. */ track(event: string, params?: Parameters): void; /** * Manually track purchase event with currency code in your application. * * @param value The value of the event. Can be price. * @param currencyCode The currency code corresponding to the price. * @param purchaseParams Key-value pairs with metrics or data associated with the event. Parameters can be * strings or numbers. You can use up to 200 different parameter names in your app. * @param purchaseEvent Name of the event. */ trackPurchase(value: number, currencyCode: string, purchaseParams: Parameters, purchaseEvent?: string): void; /** * Automatically tracks in app purchases ios. Only for iOS. */ trackInAppPurchasesIos(): void; /** * Tracks an in-app purchase as a Purchase event. Only for Android. * @param item The name of the item that was purchased. * @param priceMicros The price in micros in the user's local currency. * @param currencyCode The currency code corresponding to the price. * @param purchaseData Purchase data from purchase. * @param dataSignature Signature from purchase. * @param [params] Any additional parameters to track with the event. * @param [eventName] The name of the event to record the purchase under. */ trackGooglePlayPurchase(item: string, priceMicros: number, currencyCode: string, purchaseData: string, dataSignature: string, params?: Parameters, eventName?: string): void; /** * Disable automatically location collection */ disableLocationCollection(): void; /** * Set location manually. Best if used in after calling [[LeanplumSdkModule.disableLocationCollection]]. Useful if you * want to apply additional logic before sending in the location. * * @param latitude Device latitude. * @param longitude Device longitude. * @param type of the location. */ setDeviceLocation(latitude: number, longitude: number, type?: LocationAccuracyType): void; /** * Pauses the current state. You can use this if your game has a "pause" mode. You shouldn't call * it when someone switches out of your app because that's done automatically. */ pauseState(): void; /** * Resumes the current state. */ resumeState(): void; /** * Enable screen tracking. */ trackAllAppScreens(): void; /** * Advances to a particular state in your application. The string can be any value of your * choosing, and will show up in the dashboard. A state is a section of your app that the user is * currently in. * @param name of the state. State may be empty for message impression events. * @param [info] Basic context associated with the state, such as the item purchased. info is * treated like a default parameter. * @param [params] Key-value pairs with metrics or data associated with the state. Parameters can be * strings or numbers. You can use up to 200 different parameter names in your app. */ advanceTo(name: string | null, info?: string, params?: Parameters): void; /** * Register a callback for when no more file downloads are pending (either when no files needed to be * downloaded or all downloads have been completed). * @param callback to be invoked */ onVariablesChangedAndNoDownloadsPending(callback: () => void): void; /** * Register a callback to call ONCE when no more file downloads are pending (either when no files * needed to be downloaded or all downloads have been completed). * @param callback to be invoked */ onceVariablesChangedAndNoDownloadsPending(callback: () => void): void; /** * Register a callback for when a message is displayed. * @param callback Callback to be invoked with the message data as parameter, use null value * to reset. */ onMessageDisplayed(callback: ((data: ActionContextData) => void) | null): void; /** * Register a callback for when a message is dismissed. * @param callback Callback to be invoked with the message data as parameter, use null value * to reset. */ onMessageDismissed(callback: ((data: ActionContextData) => void) | null): void; /** * Register a callback for when a message action is executed. * @param callback Callback to be invoked with the message data as parameter, use null value * to reset. */ onMessageAction(callback: ((data: ActionContextData) => void) | null): void; registerForRemoteNotifications(): void; securedVars(): Promise; isQueuePaused(): Promise; setQueuePaused(paused: boolean): void; isQueueEnabled(): Promise; setQueueEnabled(enabled: boolean): void; migrationConfig(): Promise; /** * Use only for debug purposes. * Disables FCM forwarding to CT. */ disableAndroidFcmForwarding(): void; /** * Use only for debug purposes. */ forceNewDeviceId(deviceId: string): void; } export declare const Leanplum: LeanplumSdkModule; export {};