References
Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
KLP.initialize | config: { environment?: "dev" | "test" | "prod", debugMode?: boolean, showDebugScreen?: boolean } | Promise<boolean> | Initializes the native SDK at app startup. Security checks run on iOS/Android during this step. Must be called before any other SDK method. |
KLP.setUser | userId: string, accessToken: string | Promise<boolean> | Starts a user session and passes token data to the native SDK. Call after host app authentication. |
KLP.logout | — | Promise<boolean> | Ends the active user session. Call when the user signs out. |
KLP.launch | path?: string | Promise<boolean> | Opens the KLP WebView. If path is provided, opens that route (e.g. "rewards"). |
KLP.logEvent | eventName: string, attributes?: Record<string, unknown> | Promise<boolean> | Sends an engagement event to the loyalty backend. |
KLP.setTheme | theme: "system" | "light" | "dark" | Promise<boolean> | Sets the SDK theme. |
KLP.getAppearance | — | Promise<{ theme, resolvedTheme, languageTag }> | Reads the current theme and language from the native SDK. |
KLP.setLanguage | languageTag: string | null | Promise<boolean> | Overrides the SDK language. Pass null to reset to the system locale. |
KLP.isInitialized | — | Promise<boolean> | Returns whether the native SDK is successfully initialized. |
KLP.isDeviceSecure | — | Promise<boolean> | Returns the current device security status. |
KLP.performSecurityChecks | — | Promise<{ allPassed: boolean, checks: Array<{ name, passed, errorMessage? }> }> | Returns detailed security check results. |
KLP.openDebugScreen | — | Promise<boolean> | Opens the Android debug screen. Always returns false on iOS. |
Event Listeners
| Method | Callback Payload | Description |
|---|---|---|
KLP.onEventReceived | { type, data, timestamp } | Subscribes to generic events emitted from the WebView/native bridge. |
KLP.onRewardEarned | { id, name, description, imageUrl, value, type, earnedAt } | Triggered when a reward is earned. |
KLP.onError | { message, code? } | Subscribes to native SDK error events. |
KLP.onSecurityError | { allPassed, checks } | Triggered when a security check fails. |
KLP.onSSEEffects | { effects: Record<string, unknown>[] } | Subscribes to SSE (real-time effect) events. |
KLP.onDeepLink | { url, scheme?, host?, path?, queryParameters? } | Subscribes to deeplink events triggered from the WebView. |
KLP.onWebViewClosed | — | Triggered when the SDK-opened WebView is closed. |
KLP.onThemeChanged | { theme, resolvedTheme } | Triggered when the native SDK theme changes. |
KLP.onLanguageChanged | { languageTag } | Triggered when the native SDK language changes. |
All listeners return { remove: () => void }. Call .remove() when you no longer need the subscription.
Updated about 1 month ago
Did this page help you?
