Integrate the Android SDK
Runtime Toggles
Integrate with Other Platforms
Handle URLs
Changelog
To use mobile app messaging features in your app, integrate the Mobile App Messaging SDK and its dependencies into your app.
Update the settings.gradle file for your app to include the required dependencies for the SDK.
Replace {currentVersion} in this example with the latest SDK version number from the change log.
Note
1dependencyResolutionManagement {
2 repositories {
3 maven ("https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository")
4 // other repositories
5 }
6}
7
8dependencies {
9 implementation 'com.salesforce.marketingcloud:mobileappmessagingsdk:{currentVersion}'
10}Initialize the SDK during the execution of the onCreate method for your Application class. This code example shows how to initialize the SDK.
1class SDKTestApp : Application() {
2
3 override fun onCreate() {
4 super.onCreate()
5 if(BuildConfig.DEBUG){
6 // Debug logging for all modules enabled for debug builds
7 SFMCSdk.setLogging(LogLevel.DEBUG, LogListener.AndroidLogger())
8 // Enable debug logging just for MAM module
9 SFMCSdk.setLogging(LogLevel.DEBUG, LogListener.AndroidLogger(), ModuleLogger.MAM)
10 }
11
12 SFMCSdk.configure(this, SFMCSdkModuleConfig.build {
13 this.mamModuleConfig = MobileAppMessagingConfig.builder()
14 .moduleApplicationId("YOUR_APP_ID")
15 .tenantId("YOUR_TENANT_ID")
16 .accessToken("YOUR_ACCESS_TOKEN")
17 .endpointUrl("ENDPOINT_URL")
18 .build()
19 }){ initStatus ->
20 // Handle initialization status
21 }
22 }
23}If you don’t call the SDK’s configure method and initialize the mamModuleConfig from your app’s onCreate method, the SDK can’t send notifications to the app while it’s in the background.