Integration

Session & WebView

  • Repeated setUser with the same user and active connection is a no-op.
  • A different userId closes the previous session and refreshes channels.
  • launch(activity) opens the default loyalty WebView. URLs and security endpoints are SDK-managed.
  • nameInitials is passed as the nameInitials query parameter and X-User-Initials header.
ActionResult
First setUser after loginSession stored; SSE starts
App restartSession 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 default

Theme (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 again

Debug modes

MethodEffect
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.


Did this page help you?