Integrate the MobilePush Android SDK
To use any MobilePush functionality in your app, integrate the MobilePush Android 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.
To use the latest SDK version, replace {currentVersion}
with the latest version number available on the SDK Releases page.
The MobilePush Android SDK no longer declares the Google Play Services Location or AltBeacon libraries as required dependencies. If your application requires these features, enable them by following the instructions provided in Implement Location Messaging in Android.
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.
The SDK must be initialized during the execution of your Application class’s onCreate
method. Initialization requires configuration data for your Marketing Cloud Engagement application. For guidance on where to find the required account-related information see Retrieve Required SDK Configuration Data.
From MobilePush SDK version 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
method, the SDK can’t post notifications while the app is in the background.
To troubleshoot the InitializationStatus
returned during the SDK’s initialization call, see Troubleshoot Initialization and Registration.
You can customize the display and handling of notifications. For guidance on customizing notification, see Customize Push Notification Functionality for Android Apps.
Starting with Android 13, a new runtime permission is required for displaying notifications. This change impacts all applications operating on Android 13 or later versions. Your app can't display notifications until the user grants this permission. For more information, see Request runtime permissions on the Android Developers website.
After the user has accepted the permission to display notifications, you must notify the SDK:
Send a test push notification from Engagement to your app by following the instructions provided in Send a Test Push.