Integration
Session & WebView
- Repeated
setUserwith the same user and active connection is a no-op. - A different
userIdcloses the previous session and refreshes channels. launch(activity)opens the default loyalty WebView. URLs and security endpoints are SDK-managed.nameInitialsis passed as thenameInitialsquery parameter andX-User-Initialsheader.
| Action | Result |
|---|---|
First setUser after login | Session stored; SSE starts |
| App restart | Session restored on initialize() |
logout() | Session cleared; SSE stopped |
Locale
The SDK reads language from Configuration and adds lang and Accept-Language to WebView requests.
// config time
KLPConfig.Builder().setLocaleProvider { /* return Locale */ }
// runtime
KLP.getInstance().setLocale(locale)
KLP.getInstance().setLocale(null) // revert to defaultTheme (light / dark)
System night mode is watched; a theme parameter is appended to the WebView URL.
With Jetpack Compose, notify the SDK when theme changes:
if (KLP.isInitialized()) {
KLP.getInstance().setTheme(darkTheme = isDark)
}
KLP.getInstance().setTheme(null) // follow system againDebug modes
| Method | Effect |
|---|---|
setDebugMode(true) | Relaxes security checks, more logging. Use false in production. |
setDebugScreenEnabled(true) | Enables internal debug UI. Internal testing only. |
KLP.openDebugScreen(activity)Loyalty entry widget
XML:
<com.klp.sdk.ui.KLPWidgetView
android:layout_width="match_parent"
android:layout_height="wrap_content" />Jetpack Compose:
@Composable
fun KlpEntryWidget(modifier: Modifier = Modifier) {
AndroidView(modifier = modifier, factory = { KLPWidgetView(it) })
}If the SDK is not initialized, the view takes no space. Tap opens the WebView.
Updated about 2 months ago
Did this page help you?
