The Airship Flutter module allows a developer to integrate push notification services with Flutter apps targeting both Android and iOS. This module is designed to be cross-platform, and applications using it can leverage the same code on both platforms.
- Dart SDK 2.1+
- Flutter 1.7.8+
- To use notifications:
- Xcode 11+
- Airship SDK 12+
- minSdkVersion 16+
- compileSdkVersion 28+
1) Add the airship dependency to your package's pubspec.yaml file:
dependencies: airship: ^1.0.0
2) Install your flutter package dependencies by running the following in the command line at your project's root directory:
3) Import airship into your project:
1) Download the Firebase google-services.json file and place it inside android/app.
2) Apply the com.google.gms.google-services plugin to the android/app.
3) Create a new airshipconfig.properties file with your application’s settings and place it inside the android/app/src/main/assets directory:
developmentAppKey = Your Development App Key developmentAppSecret = Your Development App Secret productionAppKey = Your Production App Key productionAppSecret = Your Production Secret # Toggles between the development and production app credentials # Before submitting your application to an app store set to true inProduction = false # LogLevel is "VERBOSE", "DEBUG", "INFO", "WARN", "ERROR" or "ASSERT" developmentLogLevel = DEBUG productionLogLevel = ERROR # Notification customization notificationIcon = ic_notification notificationAccentColor = #ff0000 # Optional - Set the default channel notificationChannel = "customChannel"
1) Add the following capabilities to your application target:
- Push Notifications
- Background Modes > Remote Notifications
2) Create a plist AirshipConfig.plist and include it in your application’s target:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>developmentAppKey</key> <string>Your Development App Key</string> <key>developmentAppSecret</key> <string>Your Development App Secret</string> <key>productionAppKey</key> <string>Your Production App Key</string> <key>productionAppSecret</key> <string>Your Production App Secret</string> </dict> </plist>
3) Optional. In order to take advantage of iOS 10 notification attachments, such as images, animated gifs, and video, you will need to create a notification service extension by following the iOS Notification Service Extension Guide.
Send Your First Push Notification
At this point in the guide, if you followed all the steps above you should be ready to send a test push notification to verify everything is set up properly.
Before sending a push, you must enable user notifications. The plugin does not enable user notifications by default in order to avoid prompting the user for permissions. But for a testing purposes, you can enable user notifications as soon as the application is ready. You may also want to set default foreground presentation options to display the notification in the foreground on iOS.