Integrate the Mobile App Messaging SDK with your Android App

To use mobile app messaging features in your app, integrate the Mobile App Messaging SDK and its dependencies into your app. The integration involves adding the SDK repository within dependencyResolutionManagement in settings.gradle, and the marketingcloudsdk dependency in your app’s module-level build.gradle file, as shown in this example.

Replace {currentVersion} in this code example with the latest SDK version number from the change log.

Set up Firebase Cloud Messaging by following the Android Firebase Setup documentation. When you add the Firebase core dependency to your module’s build.gradle file, use com.google.firebase:firebase-core:23.x.x.

If you initialize the FirebaseApp manually, you must initialize Firebase before initializing the SDK.

Initialize the SDK during the execution of the onCreate method for your Application class. This code example shows how to initialize the SDK.

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.

You can customize the display and handling of notifications. See Customize Push Notification for Android Apps.

Android 13 and later require a specific runtime permission to display notifications. Your app can’t display notifications until the user grants this permission. For more information, see Request runtime permissions on the Android Developers website.

To notify the SDK that the user accepted the request to display notifications, use this code.

Use this code example to add support for push notifications to your app. Replace YOUR_SENDER_ID with the sender ID for your app. You can find the sender ID on the Project Settings page of the Firebase console.