Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in your application and access to the features of Infobip IP Messaging Platform. The document describes plugin integration steps for your Flutter project.
- Flutter 3.3.0+
For iOS project:
- Xcode 13.4.1
- Minimum deployment target 12.0
For Android project:
- Android Studio
- Supported API Levels: 21 (Android 5.0 - Lollipop) - 34 (Android 14)
This guide is designed to get you up and running with Mobile Messaging SDK plugin for Flutter
-
Make sure to setup application at the Infobip portal, if you haven't already.
-
Add MobileMessaging plugin to dependencies at
pubspec.yaml
:
dependencies:
infobip_mobilemessaging: '^6.1.0'
-
Run
flutter pub get
to install plugin -
Configure platforms
-
iOS
- Update the
ios/Podfile
with iOS deployment target platform 12.0 -platform :ios, '12.0'
if needed, and perform in Terminalcd ios && pod update
- Import MobileMessaging
@import MobileMessaging;
and add[MobileMessagingPluginApplicationDelegate install];
into<ProjectName>/ios/Runner/AppDelegate.m
(this is required for OS callbacks such asdidRegisterForRemoteNotifications
to be intercepted by native MobileMessaging SDK) :
... @import MobileMessaging; @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [MobileMessagingPluginApplicationDelegate install]; ... } ...
expand to see Swift code
import MobileMessaging ... @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { ... MobileMessagingPluginApplicationDelegate.install() ... } } ...
- Configure your project to support Push Notification as described in item 2 of iOS integration quick start guide
- Integrate Notification Service Extension into your app in order to obtain:
- more accurate processing of messages and delivery stats
- support of rich notifications on the lock screen
- Update the
-
Android
- Add 'com.google.gms:google-services' to
android/build.gradle
file
buildscript { ... dependencies { ... //Google Services gradle plugin classpath 'com.google.gms:google-services:4.3.10' } }
- Add
apply plugin: 'com.google.gms.google-services'
at the end of yourandroid/app/build.gradle
in order to apply Google Services Gradle Plugin - Setup Firebase for your project and add a Firebase configuration file (google-services.json) to the app as described in
Firebase documentation
. Usually it needs to be added intoandroid/app
folder.
If you want to provide the Firebase configuration differently, check Applying Firebase configuration
Starting from Android 13, Google requires to ask user for notification permission. Follow this guide to make a permission request.
- Add 'com.google.gms:google-services' to
-
-
Use plugin in your Dart code:
import 'package:infobip_mobilemessaging/infobip_mobilemessaging.dart'; import 'package:infobip_mobilemessaging/models/configuration.dart'; import 'package:infobip_mobilemessaging/models/library_event.dart'; ... await InfobipMobilemessagingFlutterPlugin.init(Configuration( applicationCode: "<Your app code>", iosSettings: IOSSettings( notificationTypes: ["alert", "badge", "sound"], logging: true ) )); InfobipMobilemessaging.on(LibraryEvent.MESSAGE_RECEIVED, (Message event) => { print("Callback. MESSAGE_RECEIVED event, message text: ${event.body}") }); ...
More details on SDK features and FAQ you can find on Wiki
NEXT STEPS: Users and installations