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+
  • Airship SDK 12+

Android

  • minSdkVersion 16+
  • compileSdkVersion 28+

Installation

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:

flutter pub get

3) Import airship into your project:

import 'package:airship/airship.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"

iOS Setup

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.

Enable user notifications
Airship.setUserNotificationsEnabled(true);