Add the Flutter plug-in to your app


To start configuring basic mobile app messaging in Flutter projects for iOS and Android apps, create an example app in Flutter and then configure and build your Android and iOS apps. After configuring basic mobile app messages, you can configure advanced mobile app messaging features.



When Acoustic Mobile App Messaging stores data that you send, the data is not encrypted; therefore, it is recommended that you do not transmit sensitive information in the inbox, in-app, and mobile app messages. The data is not encrypted in our databases or log files or when stored on the device. If you must transmit sensitive information, encrypt the data before sending it and decrypt the data in memory on the device.

Before you begin

Set up the appropriate environment. For more information, see Set up an editor.



The Acoustic Flutter SDK supports Flutter SDK version >=2.12.0 <3.0.0. Verify the correct Flutter SDK is installed when setting up your environment.

Create a Flutter application

Use the flutter create command to create a new project:

$ flutter create myapp
$ cd myapp

You can also pass other arguments to the flutter create command, such as the project name (pubspec.yml), the organization name, or specify the programming language used for the native platform. For more information, see Create the app.

$ flutter create --project-name myapp --org dev. Flutter --android-language java --ios-language objc myapp
$ cd myapp



To add Flutter to an existing application, see Add Flutter to existing app.

Install Acoustic Flutter plug-in

  1. Download the Acoustic Flutter plug-in.
  2. Add your application to the Root/Applications directory in the Flutter plug-in. The Acoustic Flutter plug-in repo is structured as follows:
  -<add your applications>
  -<all the plug-ins here>

The Acoustic Flutter plug-in is packaged as separate plug-ins with various peer dependencies. The peer dependencies are listed in the pubspec.yaml file for the respective plug-in.

Link the plug-ins

To link the plug-ins to your application, you can add them as dependencies in your app's pubspec.yaml file as follows:



If you are using VSCode, it automatically runs the flutter pub get command which installs the plug-ins to your app.

If you are not using VSCode, you must manually run the flutter pub get command after adding the new dependencies.

    sdk: flutter
    path: ../../plugins/flutter_acoustic_mobile_push
    path: ../../plugins/flutter_acoustic_mobile_push_inbox
    path: ../../plugins/flutter_acoustic_mobile_push_beacon
    path: ../../plugins/flutter_acoustic_mobile_push_geofence
    path: ../../plugins/flutter_acoustic_mobile_push_inapp
    path: ../../plugins/flutter_acoustic_mobile_push_location



The location plug-in is required if you use the beacon or geofence plug-ins.



The example paths to the plug-ins assume you placed the app in the same directory as the sample app. If you place your app in a different directory, update the paths accordingly.

Set up your iOS project

When creating a new Flutter project, the iOS platform's default version is 9.0. The Acoustic Flutter plugin requires a minimum version of 12.1.

Update the pod file

To update the iOS platform:

  1. Open the podfile in your app's iOS directory.
  2. Replace # platform :ios, '9.0' with platform :ios, '12.1'.
  3. Change into the iOS directory cd ios.
  4. Install the pods using the pod install command.

Use the plug-ins in your app

You can import the .dart files directly into your application:

import 'package:flutter_acoustic_mobile_push/flutter_acoustic_sdk_push.dart';
import 'package:flutter_acoustic_mobile_push_inbox/inbox/messages/inbox_messages.dart';
import 'package:flutter_acoustic_mobile_push_inapp/flutter_acoustic_mobile_push_inapp.dart';
import 'package:flutter_acoustic_mobile_push_location/location.dart';

For more information about using each plug-in, see examples provided in the sample in the applications/sample/ folder.

Update the project version

To update the project version:

  1. Open your .xcworkspace file.
  2. Select your main app target.
  3. In the General tab, set the Minimum Deployments version to 12.1.

Integrate the SDK into your app

  1. Download the MceConfig file and add it to all your application project's targets. For more information about MceConfig, see Configuration (MceConfig.json).
  2. Set your team and provisioning profile in the Signing and Capabilities tab. You must complete this step before the app has permission to get the APNs deviceToken.
  3. For the pod target and the app target, go to the Build Settings tab and set Set Build Active Architectures Only to No. You must set it to No for both Debug and Release.
  4. Set Push Notification capability in Target Capabilities.
  5. Add App Group capability to your main application target. Be sure to create and check the checkmark for the App Group in the interface.
  6. Add the Keychain Sharing capability to your main application target. Be sure to add a Keychain Group value to the list.
  7. Turn on location updates if you want to use locations or beacons with your app:
  • Go to the Capabilities tab for your target > Background Modes section.
  • Select Location updates. For more information, see Device Location Awareness (DLA Device Location Awareness (DLA).

Automated integration

The iOS SDK is compatible with the Swift programming language. Any version of the SDK before v3.6.10 does not work with Swift Application Delegates. You can use a workaround by using an Objective-C delegate class. Usage of the SDK from Swift is demonstrated in the Swift sample project starting with V3.6.10.

  1. The automatic integration method requires a main.swift file to be created in the project. It should contain the following:
import UIKit
import AcousticMobilePush

let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))
let _ = UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(MCEAppDelegate.self) )
  1. In order for Swift to use the classes in the SDK, you must import the framework at the top of the Swift files that use it. For more information, see Apple Developer documentation.
import AcousticMobilePush



When you use Swift, prefix the package name to the appDelegateClass in the MCEconfig file.

  "appDelegateClass": "Sample.AppDelegate"
  ... // Rest of MceConfig.json file
  1. Add the following import directive to the top of the AppDelegate.
import UserNotifications
  1. Add didFinishLaunchingWithOptions to the application method in your AppDelegate class. This code sets the notification type to badge, sound, and alert. You can remove the unwanted notification types from each OS support level declaration.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {

    // iOS 10+ Example static action category:
    let acceptAction = UNNotificationAction(identifier: "Accept", title: "Accept", options: [.foreground])
    let rejectAction = UNNotificationAction(identifier: "Reject", title: "Reject", options: [.destructive])
    let category = UNNotificationCategory(identifier: "example", actions: [acceptAction, rejectAction], intentIdentifiers: [], options: [.customDismissAction])
    var categories = Set()
    // iOS 10+ Push Message Registration
    let center = UNUserNotificationCenter.current()
    center.requestAuthorization(options: [.alert, .sound, .carPlay, .badge], completionHandler: { (granted, error) in
        if let error = error {
            print("Could not request authorization from APNS \(error.localizedDescription)")
    return true

For more information about integrating the iOS SDK to your app, see Add the iOS SDK to your app

Update the SDK configuration

  1. Open the MceConfig.json file.
  2. Swift requires your class to be in a namespace. For example, update the appDelegateClass value to SwiftSample.AppDelegate in the Swift sample app.
  3. Update the dev and prod entries in the appKey section to match the App Keys created in the web portal.
    • The dev entry is used when you run the app from Xcode with a development provisioning profile. The prod entry is used when you run the app with an App Store, Enterprise, or AdHoc provisioning profile.
    • If you do not have a production App Key, use apXXXXXXXX for the prod entry.
  4. Update the baseUrl entry to match the server for your App Key. The baseURL was provided when your account was provisioned for mobile app messaging.
  5. If you are not using Geofences or iBeacons, you can remove the location entry and all its children.
  6. If you are using iBeacons, update the UUID in the iBeacon section of the location entry. The UUID should match the UUID for your iBeacons.

For more information, see Configuration (MceConfig.json).

Now you can compile and run the app to start communication with the Acoustic servers. Use the verbose logs in the MceConfig.json file to debug.

Customize push notifications

Push notifications are accessed through a notification channel. You can customize the push notifications by customizing the notification channel function. To access the function:

  1. Go to the root directory of the project > plugins folder.
  2. Go to flutter_acoustic_mobile_push > android >src >main >kotlin > co > acoustic > flutter > sdk > flutter_acoustic_mobile_push and open the MainApplication.kt file.
  3. In the MainApplication.kt file, find the following code:
private fun createNotificationChannel() {

The createNotificationChannel function adds the functionality for push notifications.

  1. Customize this function to customize the push notifications.

Set up your Android project

Add gson package

  1. In the directory for android/app, create a directory labeled libs.
  2. Download the gson 2.2.4 jar from Download gson JAR 2.2.4 with all dependencies.
  3. Unzip the downloaded file.
  4. Place the gson-2.2.4.jar file inside the newly created libs directory.

Update the build.gradle file

  1. Open the build.gradle file located in android/build.gradle and inside of dependencies add classpath "" .
  2. Delete the section for allprojects with the following:
    rootProject.allprojects {
        repositories {
            // added `libs` as dependency location
            flatDir {
                dirs 'libs'

Update the app's build.gradle file

  1. Open build.gradle located in android/app/build.gradle and after the line apply from:" $flutterRoot/packages/flutter_tools/gradle/flutter.gradle" add the following:

    rootProject.allprojects {
    		repositories {
    				// added `libs` as dependency location
    				flatDir {
    						dirs 'libs'
  2. In the android bracket, change compileSdkVersion flutter.compileSdkVersion to compileSdkVersion 33.

  3. Inside the android bracket, add the following:

    sourceSets { += 'src/main/kotlin'
  4. Inside the android bracket, there will be a bracket for defaultConfig change minSdkVersion flutter.minSdkVersion to minSdkVersion 23.
    Change targetSdkVersion flutter.targetSdkVersion to targetSdkVersion30. Lastly, after versionNameflutterVersionName, add the following:

    multiDexEnabled true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  5. After the bracket for buildTypes, add the following:

    packagingOptions {
    	exclude 'META-INF/NOTICE'
    	exclude 'META-INF/LICENSE'
  6. Replace the dependencies with the following:

    dependencies {
    	implementation fileTree(dir: 'libs', include: ['*.jar, *.aar'])
    	implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation 'androidx.multidex:multidex:2.0.1' //with androidx libraries
    	implementation ''
      testImplementation 'junit:junit:4.12'
    	androidTestImplementation 'androidx.test:runner:1.2.0'
    	androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    apply plugin: ''

Update the AndroidManifest.xml file

  1. Update the AndroidManifest.xml file in android/app/src/main/ and make the following meta-data changes.

  2. After the manifest opening tag, add:

    1. <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    2. Inside of application delete android:name=" ${applicationName}"

    3. Outside of application and before activity add the following: Replace "INSERT-API-KEY-HERE" with your Google Maps Key.

      <meta-data android:name=""
    4. After theΒ  meta-data section for android:name="" add the following:

    5. After the intent-filler section for android:name= "android.intent.action.MAIN" add the following:

        <action android:name="FLUTTER_NOTIFICATION_CLICK" />
      	<category android:name="android.intent.category.DEFAULT" />
      	<action android:name="co.acoustic.flutter.openInboxMessage" />
      	<category android:name="android.intent.category.DEFAULT" />
    6. After the meta-data section for android:name= "flutterEmbedding," add the following:

      <!-- geofence services -->
      	android:stopWithTask="true" />

Create a MceConfig JSON file

  1. Create a directory labeled assets in the android/app/src/main/.
  2. Inside this assets directory, create a file labeled MceConfig.json.
  3. To configure this file, see Configuration (MceConfig.json).

Final Step

Copy your google-services.json file and add it to the android/app/ directory.