Initial Configuration
Create a platform-specific configuration object and pass it to enable().
- Android
- Kotlin Multiplatform
- iOS
- Web
The SDK provides two entry points depending on your project type:
com.sap.ec.android.EngagementCloud— for Android apps onlycom.sap.ec.EngagementCloud— for Kotlin Multiplatform (KMP) projects that share code across platforms
| Scenario | Recommended Entry Point |
|---|---|
| Android app only | com.sap.ec.android.EngagementCloud |
| KMP project sharing code across platforms | com.sap.ec.EngagementCloud |
info
For a detailed comparison, see Android and Kotlin Multiplatform Differences.
val config = AndroidEngagementCloudSDKConfig(
applicationCode,
launchActivityClass
)
applicationCodeis astringvalue of the application code in SAP Engagement Cloud.launchActivityClassis an optionalActivityclass that handles app launch events, such as push message opens.
val config = SdkConfig(
applicationCode
)
applicationCodeis astringvalue of the application code in SAP Engagement Cloud.
let config = EngagementCloudConfig(
applicationCode: "<your-application-code>"
)
applicationCodeis astringvalue of the application code in SAP Engagement Cloud.
const config = JsEngagementCloudSDKConfig(
applicationCode,
serviceWorkerOptions
)
applicationCodeis astringvalue of the application code in SAP Engagement Cloud.serviceWorkerOptionsis an optionalServiceWorkerOptions
const serviceWorkerOptions = ServiceWorkerOptions(
applicationServerKey,
serviceWorkerPath,
serviceWorkerScope
)
applicationServerKeyis thestringvalue of the VAPID public key that is used to set up the Web Push feature in SAP Engagement Cloud.serviceWorkerPathis the path to theems-service-worker.serviceWorkerScopeis an optionalstringvalue to set the range of URLs that a service worker can control.
Validating the Configuration
During the enable() call, the SDK validates:
- All platforms: Application code is provided (non-empty) and its format is correct.
- Web: Service worker path exists and scope is valid.
- Android: Launch activity class exists and is accessible (reflective accessibility).
Any validation errors are returned in the Result or the thrown error for Swift and JavaScript. The SDK logs the error and aborts the enable call gracefully, without affecting app stability.
Optional and Required Fields
| Field | Platform | Required | Notes |
|---|---|---|---|
| applicationCode | All | Required | Without it, tracking does not work because the backend rejects requests. |
| launchActivityClass | Android | Optional | Is required for deep-link launches with push. |
| serviceWorkerOptions | Web | Optional | Only required for Web Push. When not using Web push, it's omitted. |
| applicationServerKey | Web | Required (for push) | VAPID key must match your settings in SAP Engagement Cloud. |
Dynamic Configuration Changes
To switch environments (for example, staging to production) or change application codes:
- Call
disable(). - Call
changeApplicationCode(newCode)if the app code changed. - Call
enable()with the new configuration. - Re-link contact if needed.
Security Recommendations
- Never hard-code secrets in your configuration.
- Validate that the application code source is authentic.