Initialization

Before the Data Cloud Module for the Engagement Mobile SDK can be used to invoke web services using the API, the SDK must be configured. Use the CdpConfigBuilder for iOS or CdpConfig.Builder for Android helper class to build your SDK configuration by providing required settings appId and endpoint that can be obtained from your Mobile Connector. Optionally, configuration can be provided for the settings trackScreens, trackLifecycle, and sessionTimeoutInSeconds.
Setting Field Type Description
appId string Required. The appId setting uniquely identifies your mobile application to Data Cloud and must be in a valid universally unique identifier, UUID, format. An invalid appID results in an error.
endpoint string Required. The endpoint setting tells the SDK where to send the events being created and tracked.
sessionTimeoutInSeconds integer The sessionTimeoutInSeconds setting represents the number of seconds the mobile application can remain in the background before the current session is expired. When a customer launches the mobile application, the SDK starts a new session that is maintained while the app is in the foreground. If the customer sends the mobile application to the background, the SDK starts a timer to expire the current session. If the customer brings the mobile app back to the foreground before the session expiration, the timer is cleared and the session is continued. Otherwise the session expires. This field is set to 600 by default.
trackLifecycle boolean Enable trackLifecycle to automatically track AppForegrounded, AppBackgrounded, and AppVersionChanged behavior events. This field is set to false by default.
trackScreens boolean Enable trackScreens to automatically track the mobile app ScreenEntry behavior event. This field is set to false by default.
Set up the Data Cloud Module.
  1. Configure the Data Cloud Module.
  2. Initialize the Engagement Mobile SDK with the Data Cloud Module.
Configuration happens during the initialization routine of the Mobile application being instrumented.

iOS

1import Cdp
2import SFMCSDK
3
4...
5
6let appId = "{appIdFromMobileConnector}"
7let endpoint = "https://{endpointFromMobileConnector}"
8
9// 1. configure the Data Cloud module
10let cdpModuleConfig = CdpConfigBuilder(appId: appId, endpoint: endpoint)
11        .trackScreens(false)
12        .trackLifecycle(false)
13        .sessionTimeout(600)
14        .build()
15  
16// 2. initialize the Engagement Mobile SDK      
17SFMCSdk.initializeSdk(ConfigBuilder().setCdp(config: cdpModuleConfig).build())

Android

1import com.salesforce.marketingcloud.cdp.CdpConfig
2import com.salesforce.marketingcloud.sfmcsdk.SFMCSdk
3import com.salesforce.marketingcloud.sfmcsdk.SFMCSdkModuleConfig
4
5...
6
7val appId = "{appIdFromMobileConnector}"
8val endpoint = "https://{endpointFromMobileConnector}"
9
10// 1. configure the Data Cloud module
11val cdpModuleConfig = CdpConfig.Builder(this, appId, endpoint)
12      .trackScreens(false)
13      .trackLifecycle(false)
14      .sessionTimeout(600)
15      .build()
16
17// 2. initialize the Engagement Mobile SDK 
18SFMCSdk.configure(this, SFMCSdkModuleConfig.build {
19    this.cdpModuleConfig = cdpModuleConfig
20})