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, as shown in this example.
To use the latest SDK version, replace {currentVersion} in this code sample with the latest version number available on the SDK Releases page.
The MobilePush SDK no longer declares the Google Play Services Location or AltBeacon libraries as required dependencies for Android app. If your application requires these features, enable them.
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. 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.
If you use version 10 of the SDK, use this code.
From MobilePush SDK version 8, use SFMCSdk to initialize the MarketingCloudSdk.
If you use version 7 of the SDK, use this code.
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 to display notifications. This change impacts all applications that run on Android 13 or later. 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 accepts the request to display notifications, notify the SDK using this code.
Send a test push notification from Engagement to your app by following the instructions provided in Send a Test Push.