Skip to main content

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.

EngagementCloud.config.getApplicationCode()

getClientId

Returns the client ID as a string.

EngagementCloud.config.getClientId()

getLanguageCode

Returns the language code as a string.

EngagementCloud.config.getLanguageCode()

getApplicationVersion

Returns the application version as a string.

EngagementCloud.config.getApplicationVersion()

getSdkVersion

Returns the SDK version as a string.

EngagementCloud.config.getSdkVersion()

getCurrentSdkState

Returns the SDK state as an SdkState enum: Active, OnHold, Initialized, or UnInitialized.

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

SdkStateDescription
ActiveThe SDK is enabled and processing requests.
OnHoldThe SDK is temporarily paused, for example during an application code change.
InitializedThe SDK is initialized but not yet enabled.
UnInitializedThe SDK is not initialized.

changeApplicationCode

Changes the application code. The new code is validated before the change takes effect.

warning

Changing the application code automatically resets the contact to anonymous. Call link() to re-identify the user.

EngagementCloud.config.changeApplicationCode(applicationCode)
  • applicationCode is the string value of the new application code

setLanguage

Sets the contact language. This determines the language in which contacts receive messages across all channels.

EngagementCloud.config.setLanguage(language)
  • language is the string value of the BCP-47 code of the new language Example input format: "en-US", "zh-Hans-CN"

resetLanguage

Resets the contact language to the device language.

EngagementCloud.config.resetLanguage()

getNotificationSettings

Returns the current notification settings. The return type is platform-specific.

EngagementCloud.config.getNotificationSettings()

Returns an AndroidNotificationSettings object:

PropertyTypeDescription
areNotificationsEnabledBooleanWhether notifications are enabled for the app.
importanceIntThe importance level of the notification channel.
channelSettingsList<ChannelSettings>Settings for each notification channel.

Each ChannelSettings entry contains:

PropertyTypeDescription
channelIdStringThe notification channel identifier.
importanceIntThe importance level of the channel.
canBypassDndBooleanWhether the channel can bypass Do Not Disturb.
canShowBadgeBooleanWhether the channel can show badges.
shouldVibrateBooleanWhether the channel vibrates.
shouldShowLightsBooleanWhether the channel shows lights.

Best Practices for Language Handling

  • Use valid BCP-47 codes (en-US, de-DE, zh-Hans-CN).
  • Call setLanguage only when the user changes the app language. There is no need to call it on each app start.
  • Calling resetLanguage reverts to either the device or browser language.

Failure Modes:

CauseEffect
Invalid code formatOperation returns failure result or throws (platform).
Language not supported by SAP Engagement CloudSilent fallback to the device language.

Version Introspection

To display runtime details in a diagnostics screen:

val sdkVersion = EngagementCloud.config.getSdkVersion()
val appVersion = EngagementCloud.config.getApplicationVersion()
val language = EngagementCloud.config.getLanguageCode()

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

EngagementCloud.config.setLanguage("xx-YY").onFailure { e ->
logger.warn("Language update 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.