MobilePush Flutter Plugin

Use the Flutter Plugin to integrate the MobilePush SDK into your Flutter applications.

To install the Flutter plugin, add the plugin to your application using Pub by running the following command.

The steps described in this section can vary depending on your app and the Flutter version it's using.

Navigate to android/build.gradle and add the MobilePush SDK repository.

Navigate to android/app/build.gradle and update the dependencies section to include the marketingcloudsdk dependency.

In your app's build.gradle file, ensure that the following SDK version parameters are set to the following versions.

ParameterVersion
compileSdk or compileSdkVersion35
minSdkVersion23

Ensure the org.jetbrains.kotlin.android or org.jetbrains.kotlin:kotlin-gradle-plugin specified is equal to or above 1.9.10.

Depending on your Flutter implementation, the location for specifying the Kotlin version can differ. You can specify the Kotlin version in either android/build.gradle or android/settings.gradle.

To enable push support for the Android platform, you must provide your Firebase Cloud Messaging (FCM) credentials by including the google-services.json file in your config.xml file.

  1. Download the google-services.json file from your application's Firebase console and place it in your project's android/app directory

  2. Include the Google Services plugin in your android/settings.gradle file.

    If pluginManagement isn’t present in your settings.gradle, add this dependency in android/build.gradle under the buildscript section. If there’s no buildscript section, create it.

  3. Apply the plugin in the android/app/build.gradle file by updating the plugins section.

    This step can vary depending on your implementation.

    If the plugins section doesn’t exist in your android/app/build.gradle file, add the following code at the end of the file.

If MainApplication.kt isn't present in your app, create it by extending the FlutterApplication class. Additionally, update AndroidManifest.xml.

Update MainApplication.kt in your app.

To customize push functionality, see Customize Push Notification Functionality for Android Apps.

To implement the Carousel and Button actions features introduced in Android SDK version 9.0.0, see Configure Button and Carousel Actions.

Update AndroidManifest.xml to declare the notification permission.

The SDK doesn’t automatically present URLs from these sources.

  • CloudPages URLs from push notifications
  • OpenDirect URLs from push notifications
  • Action URLs from in-app messages

To handle URLs from push notifications, follow these steps.

Navigate to MainApplication.kt and update setNotificationCustomizationOptions, as shown in the following examples.

  1. Add imports.

  2. Update setNotificationCustomizationOptions in MarketingCloudConfig.

  3. Implement the following methods in MainApplication.kt.

To handle URLs from in-app messages, set the setUrlHandler in MarketingCloudConfig as shown in the following example.

Additionally, review the additional documentation on URL Handling for Android.

If you encounter errors related to Java sealed classes or dexing, you must add the r8 dependency to your app. For more information about this error, see Google's IssueTracker.

To add the r8 dependency, update your app's settings.gradle file.

If you don't have pluginManagement in your settings.gradle file, update the buildscript.dependencies section of the android/build.gradle file.

Enable push notifications in your target’s Capabilities settings in Xcode.

Enable Push

  1. Navigate to the YOUR_APP/ios directory and open Runner.xcworkspace.

  2. To configure the SDK and enable push, update AppDelegate.

@UIApplicationMain @objc class AppDelegate: FlutterAppDelegate {

}