Getting Started

This is a developers’ guide for setting up the Airship SDK for Flutter apps.

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.

Resources

Requirements

iOS

  • Xcode 11+
  • minimum deployment target iOS 11+

Android

  • minSdkVersion 16+
  • compileSdkVersion 28+

Installation

  1. Add the airship dependency to your package’s pubspec.yaml file:
dependencies:
  airship_flutter: ^3.0.1
  1. Install your flutter package dependencies by running the following in the command line at your project’s root directory:
flutter pub get
  1. Import airship into your project:
import 'package:airship_flutter/airship_flutter.dart';

Android Setup

  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"

EU Cloud Site

If your app uses Airship’s EU cloud site, you will need to add that to airshipconfig.properties.

   # EU Cloud Site
   site = EU

iOS Setup

  1. Add the following capabilities to your application target:
  • Push Notifications
  • Background Modes > Remote Notifications
  1. 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>
 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. Mismatch 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.

  <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.

 Warning

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 to NO 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

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.

Enable user notifications
Airship.setUserNotificationsEnabled(true);