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

  1. Add the Airship dependency to your package’s pubspec.yaml file:

    
       dependencies:
          airship_flutter: ^flutterPluginVersion
       
  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_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

  1. Download the Firebase google-services.json file and place it inside android/app.

  2. Apply the com.google.gms.google-services plugin in the app-level build.gradle file.

  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. By default, the Airship SDK will use the US cloud site.

   # EU Cloud Site
   site = EU

iOS Setup

  1. Add the following capabilities to your application target:

    • Push Notifications
    • Background Modes > Remote Notifications
  2. 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.

 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