To integrate the Marketing Cloud Mobile Push Android SDK with your Android mobile app, register a device with Marketing Cloud. To register a device, add the SDK and its dependencies to your app by following these instructions.

Prerequisites

Create an app in MobilePush. This process connects the device to the MobilePush app you created previously in MobilePush.

The Android SDK requires Android API 21 or greater and has dependencies on the Android Support v4 and Google Play Services libraries.

1. Implement the SDK

Update module-level build.gradle file

Add the SDK repository:

Add the SDK dependency:

Replace {currentVersion} with 8.1.5 to use the latest SDK version.

The SDK no longer declares the Google Play Services Location or AltBeacon libraries as required dependencies. Follow the instructions for enabling Geofence and Beacon messaging if your application requires these features.

2. Set up Firebase

Follow the Android Firebase setup documentation. When you add the Firebase core dependency to your module 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.

3. Initialize the SDK

The SDK must be initialized during the execution of your Application class’s onCreate method. Initialization will require configuration data for your Marketing Cloud Application. Please refer to the documentation for guidance on where to find the required pieces of data.

From 8.0.0 onwards, use SFMCSdk to initialize the MarketingCloudSdk.

If you don’t call the SDK’s configure method and initialize the pushModuleConfig from your app’s onCreate, the SDK can’t post notifications while the app is in the background.

To troubleshoot information the InitializationStatus returned during the SDK’s initialization call, see Initialization Status in the troubleshooting section for more details.

You can customize the display and handling of notifications. See the customize notifications documentation for details.

4. Request runtime notification permission on Android 13+

Android 13 introduces a new runtime permission for showing notifications. This affects all apps running on Android 13 or higher. Your app will not be allowed to show notifications until the user has granted this permission.

See Google’s documentation for details on requesting permissions from the user.

Once the user has accepted the permission to display notifications you will need to notify the SDK:

5. Send a test push notification

Send a test push notification from the Marketing Cloud to your app.