---
schema_version: "1"
id: c7e17d3caf38f61bf85fb2f3151cfb9865b70364c7721da65bf85b7ae265854a
title: Initialization (Version 2.x)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-engagement-mobile-sdk/guides/c360a-api-engagement-mobile-sdk-initialization-v2.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-initialization-v2.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 50ce88981de7408b8f87071ddc5a8a4bb77ed131452e96023c617afc8de5c61f
products:
  - Data 360 Engagement Mobile SDK
  - Data 360 Developer Documentation
---
# Initialization (Version 2.x)

Configure the Data 360 Module for the Engagement Mobile SDK before using it to invoke web services using the API. Use the `CdpConfigBuilder` helper class for iOS or `CdpConfig.Builder` helper class for Android to build your SDK configuration by providing required settings `appId` and endpoint that can be obtained from your Mobile Connector. Optionally, configure the `trackScreens`, `trackLifecycle`, and `sessionTimeoutInSeconds` settings.

| Setting                   | Field Type | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `appId`                   | string     | Required. The `appId` setting uniquely identifies your mobile application to Data 360 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 expires. 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 continues. 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 360 Module

1.  (Optional) To capture debug information and track SDK initialization progress, set up logging before initializing the SDK. Use the `setLogger` method for iOS and the `setLogging` method for Android. For more information and example usage, see [Logging and Debugging](https://developer.salesforce.com/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-logging-and-debugging.md).
2.  Configure the Data Cloud Module.
3.  Initialize the Engagement Mobile SDK with the Data Cloud Module.

Configuration occurs during the initialization routine of the Mobile application being instrumented.

## iOS Example

```swift
import SFMCSDK
import Cdp

...

let appId = "{appIdFromMobileConnector}"
let endpoint = "https://{endpointFromMobileConnector}"

// 1. (Optional) Enable logging. In this example, the logger is set to show debug messages and higher.

SFMCSdk.setLogger(LogLevel.debug)

// 2. Configure the module

let cdpModuleConfig = CdpConfigBuilder(appId: appId, endpoint: endpoint)
        .trackScreens(false)
        .trackLifecycle(false)
        .sessionTimeout(600)
        .build()

// 3. Initialize the Engagement Mobile SDK

SFMCSdk.initializeSdk(ConfigBuilder().setCdp(config: cdpModuleConfig).build())
```

## Android Example

```java
import com.salesforce.marketingcloud.cdp.CdpConfig
import com.salesforce.marketingcloud.sfmcsdk.SFMCSdk
import com.salesforce.marketingcloud.sfmcsdk.SFMCSdkModuleConfig

// Optional, import SDK components needed to enable logging

import com.salesforce.marketingcloud.sfmcsdk.components.logging.LogLevel
import com.salesforce.marketingcloud.sfmcsdk.components.logging.LogListener.AndroidLogger

...

val appId = "{appIdFromMobileConnector}"
val endpoint = "https://{endpointFromMobileConnector}"

// 1. (Optional) Enable logging. In this example, the logger is set to show debug messages and higher.

SFMCSdk.setLogging(LogLevel.DEBUG, AndroidLogger())

// 2. Configure the module

val cdpModuleConfig = CdpConfig.Builder(this, appId, endpoint)
      .trackScreens(false)
      .trackLifecycle(false)
      .sessionTimeout(600)
      .build()

// 3. Initialize the Engagement Mobile SDK

SFMCSdk.configure(this, SFMCSdkModuleConfig.build {
    this.cdpModuleConfig = cdpModuleConfig
})
```
