References

Methods

MethodParametersReturnsDescription
KLP.initializeconfig: { 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.setUseruserId: string, accessToken: stringPromise<boolean>Starts a user session and passes token data to the native SDK. Call after host app authentication.
KLP.logoutPromise<boolean>Ends the active user session. Call when the user signs out.
KLP.launchpath?: stringPromise<boolean>Opens the KLP WebView. If path is provided, opens that route (e.g. "rewards").
KLP.logEventeventName: string, attributes?: Record<string, unknown>Promise<boolean>Sends an engagement event to the loyalty backend.
KLP.setThemetheme: "system" | "light" | "dark"Promise<boolean>Sets the SDK theme.
KLP.getAppearancePromise<{ theme, resolvedTheme, languageTag }>Reads the current theme and language from the native SDK.
KLP.setLanguagelanguageTag: string | nullPromise<boolean>Overrides the SDK language. Pass null to reset to the system locale.
KLP.isInitializedPromise<boolean>Returns whether the native SDK is successfully initialized.
KLP.isDeviceSecurePromise<boolean>Returns the current device security status.
KLP.performSecurityChecksPromise<{ allPassed: boolean, checks: Array<{ name, passed, errorMessage? }> }>Returns detailed security check results.
KLP.openDebugScreenPromise<boolean>Opens the Android debug screen. Always returns false on iOS.

Event Listeners

MethodCallback PayloadDescription
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.onWebViewClosedTriggered 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.


Did this page help you?