Flutter Setup
How to install the Airship Flutter plugin.
Requirements
- Dart SDK 2.1+
- Flutter 1.7.8+
iOS
- Xcode
13+
- minimum deployment target iOS
11+
Android
- minSdkVersion
21+
- compileSdkVersion
31+
Installation
Add the Airship dependency to your package’s
pubspec.yaml
file:dependencies: airship_flutter: ^flutterPluginVersion
Install your Flutter package dependencies by running the following in the command line, at your project’s root directory:
flutter pub get
Import Airship into your project:
import 'package:airship_flutter/airship_flutter.dart';
Initialize Airship
Airship.takeOff(APP_KEY, APP_SECRET);
Alternatively, you can load the config using the AirshipConfig.plist
on iOS and
airshipconfig.properties
file on Android as described in the following section.
Android Setup
Download the Firebase
google-services.json
file and place it insideandroid/app
.Apply the
com.google.gms.google-services
plugin in the app-levelbuild.gradle
file.Create a new
airshipconfig.properties
file with your application’s settings and place it inside theandroid/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
EU Cloud Site
If your app uses Airship’s EU cloud site, you will need to add that to airshipconfig.properties
. By default, the
Airship SDK will use the US
cloud site.
# EU Cloud Site
site = EU
iOS Setup
Add the following capabilities to your application target:
- Push Notifications
- Background Modes > Remote Notifications
Create a new
AirshipConfig.plist
file 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>
Warning Make sure that the iOS deployment target version (specified in Xcode) and the platform version (specified in your app’s Podfile) both match the current minimum target version. Mismatches between these versions can cause an
"'airship_flutter' not found"
error.
EU Cloud Site
If your app uses Airship’s EU cloud site, you will need to add that to AirshipConfig.plist
. By default, the
Airship SDK will use the US
cloud site.
<key>site</key>
<string>EU</string>
Notification Service Extension
To take advantage of notification attachments, such as images, animated gifs, and video, you will need to create a notification service extension .
Follow the CocoaPods steps in the iOS Notification Service Extension Guide.Flutter doesn’t enable bitcode by default, but bitcode is the default for new targets created manually in Xcode (such as your notification service extension). If any target uses bitcode, then all of them must use bitcode or the archival process will fail with a bitcode error. To resolve this issue, choose one of the following two options:
- If your app doesn’t require bitcode support, you can disable it in your notification service extension in Xcode by setting
Enable Bitcode
toNO
in the extension target’s Build Settings. - If your app does require bitcode support, you can edit your app’s Podfile to enable it for all the targets, using a
post_install
hook at the end of the file:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'YES'
end
end
end
Categories