Configuring at Runtime
Use these functions to read and modify the SDK's runtime configuration, including contact language and application code settings.
getApplicationCode
Returns the application code as a string, or null if not set.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getApplicationCode()
EngagementCloud.config.getApplicationCode()
await EngagementCloud.shared.config.getApplicationCode()
await window.EngagementCloud.config.getApplicationCode();
getClientId
Returns the client ID as a string.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getClientId()
EngagementCloud.config.getClientId()
await EngagementCloud.shared.config.getClientId()
await window.EngagementCloud.config.getClientId();
getLanguageCode
Returns the language code as a string.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getLanguageCode()
EngagementCloud.config.getLanguageCode()
await EngagementCloud.shared.config.getLanguageCode()
await window.EngagementCloud.config.getLanguageCode();
getApplicationVersion
Returns the application version as a string.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getApplicationVersion()
EngagementCloud.config.getApplicationVersion()
await EngagementCloud.shared.config.getApplicationVersion()
await window.EngagementCloud.config.getApplicationVersion();
getSdkVersion
Returns the SDK version as a string.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getSdkVersion()
EngagementCloud.config.getSdkVersion()
await EngagementCloud.shared.config.getSdkVersion()
await window.EngagementCloud.config.getSdkVersion();
getCurrentSdkState
Returns the SDK state as an SdkState enum: Active, OnHold, Initialized, or UnInitialized.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getCurrentSdkState()
EngagementCloud.config.getCurrentSdkState()
await EngagementCloud.shared.config.getCurrentSdkState()
await window.EngagementCloud.config.getCurrentSdkState();
On Web, the method returns a string instead of an enum. The possible values are "active", "on_hold", "un_initialized", and "initialized".
| SdkState | Description |
|---|---|
Active | The SDK is enabled and processing requests. |
OnHold | The SDK is temporarily paused, for example during an application code change. |
Initialized | The SDK is initialized but not yet enabled. |
UnInitialized | The SDK is not initialized. |
changeApplicationCode
Changes the application code. The new code is validated before the change takes effect.
Changing the application code automatically resets the contact to anonymous. Call link() to re-identify the user.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.changeApplicationCode(applicationCode)
EngagementCloud.config.changeApplicationCode(applicationCode)
await EngagementCloud.shared.config.changeApplicationCode(applicationCode)
await window.EngagementCloud.config.changeApplicationCode(applicationCode);
applicationCodeis thestringvalue of the new application code
setLanguage
Sets the contact language. This determines the language in which contacts receive messages across all channels.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.setLanguage(language)
EngagementCloud.config.setLanguage(language)
await EngagementCloud.shared.config.setLanguage(language)
await window.EngagementCloud.config.setLanguage(language);
languageis thestringvalue of theBCP-47code of the new language Example input format: "en-US", "zh-Hans-CN"
resetLanguage
Resets the contact language to the device language.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.resetLanguage()
EngagementCloud.config.resetLanguage()
await EngagementCloud.shared.config.resetLanguage()
await window.EngagementCloud.config.resetLanguage();
getNotificationSettings
Returns the current notification settings. The return type is platform-specific.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.getNotificationSettings()
Returns an AndroidNotificationSettings object:
| Property | Type | Description |
|---|---|---|
areNotificationsEnabled | Boolean | Whether notifications are enabled for the app. |
importance | Int | The importance level of the notification channel. |
channelSettings | List<ChannelSettings> | Settings for each notification channel. |
Each ChannelSettings entry contains:
| Property | Type | Description |
|---|---|---|
channelId | String | The notification channel identifier. |
importance | Int | The importance level of the channel. |
canBypassDnd | Boolean | Whether the channel can bypass Do Not Disturb. |
canShowBadge | Boolean | Whether the channel can show badges. |
shouldVibrate | Boolean | Whether the channel vibrates. |
shouldShowLights | Boolean | Whether the channel shows lights. |
EngagementCloud.config.getNotificationSettings()
Returns a NotificationSettings object with the cross-platform subset of notification settings. Available fields depend on the platform target, but the return type is consistent across all KMP targets.
await EngagementCloud.shared.config.getNotificationSettings()
Returns an IosNotificationSettings object:
| Property | Type | Description |
|---|---|---|
authorizationStatus | IosAuthorizationStatus | The app's notification authorization status. |
soundSetting | IosNotificationSetting | Whether sounds are enabled. |
badgeSetting | IosNotificationSetting | Whether badges are enabled. |
alertSetting | IosNotificationSetting | Whether alerts are enabled. |
notificationCenterSetting | IosNotificationSetting | Whether notifications appear in Notification Center. |
lockScreenSetting | IosNotificationSetting | Whether notifications appear on the lock screen. |
carPlaySetting | IosNotificationSetting | Whether notifications appear in CarPlay. |
alertStyle | IosAlertStyle | The alert style for notifications. |
showPreviewsSetting | IosShowPreviewSetting | The preview display setting. |
criticalAlertSetting | IosNotificationSetting | Whether critical alerts are enabled. |
providesAppNotificationSettings | Boolean | Whether the app provides its own notification settings UI. |
scheduledDeliverySetting | IosNotificationSetting | Scheduled delivery setting (iOS 15.0+). |
timeSensitiveSetting | IosNotificationSetting | Time-sensitive notification setting (iOS 15.0+). |
await window.EngagementCloud.config.getNotificationSettings();
Returns a WebNotificationSettings object:
| Property | Type | Description |
|---|---|---|
permissionState | PermissionState | The push notification permission state: "granted", "denied", or "prompt". |
isServiceWorkerRegistered | Boolean | Whether the push service worker is registered. |
isSubscribed | Boolean | Whether the user is subscribed to push notifications. |
Best Practices for Language Handling
- Use valid BCP-47 codes (
en-US,de-DE,zh-Hans-CN). - Call
setLanguageonly when the user changes the app language. There is no need to call it on each app start. - Calling
resetLanguagereverts to either the device or browser language.
Failure Modes:
| Cause | Effect |
|---|---|
| Invalid code format | Operation returns failure result or throws (platform). |
| Language not supported by SAP Engagement Cloud | Silent fallback to the device language. |
Version Introspection
To display runtime details in a diagnostics screen:
- Android
- Kotlin Multiplatform
- iOS
- Web
val sdkVersion = EngagementCloud.config.getSdkVersion()
val appVersion = EngagementCloud.config.getApplicationVersion()
val language = EngagementCloud.config.getLanguageCode()
val sdkVersion = EngagementCloud.config.getSdkVersion()
val appVersion = EngagementCloud.config.getApplicationVersion()
val language = EngagementCloud.config.getLanguageCode()
let version = try? await EngagementCloud.shared.config.getSdkVersion()
const version = await window.EngagementCloud.config.getSdkVersion();
Thread-Safety and Concurrency
All configuration reads are fast and safe from any thread. Language and application code changes are serialized internally. Debounce user-facing controls to avoid triggering multiple concurrent changes.
Error Handling Examples
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.config.setLanguage("xx-YY").onFailure { e ->
logger.warn("Language update failed", e)
}
EngagementCloud.config.setLanguage("xx-YY").onFailure { e ->
logger.warn("Language update failed", e)
}
do { try await EngagementCloud.shared.config.setLanguage("en-GB") } catch { print("Language failed: \(error)") }
try { await window.EngagementCloud.config.setLanguage("en-GB"); } catch(e) { console.error("Language failed", e); }
Observability Tips
- Log the application code and SDK version once after calling
enable(). - Include language and contact state in support bundles.
- Mask sensitive tokens.