Flutter Setup

How to install the Airship Flutter plugin.

Requirements

  • Dart SDK 2.17.3+
  • Flutter 3.0.2+

iOS

  • Xcode 14.3+
  • minimum deployment target iOS 14+

Android

  • minSdkVersion 21+
  • compileSdkVersion 33+

Installation

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

    
       dependencies:
          airship_flutter: ^7.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_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 in the app-level build.gradle file.

iOS Setup

  1. Add the following capabilities to your application target:

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

Calling TakeOff

takeOff should be called in a standard application at the beginning of the lifecycle. Once takeOff is called, the config will be stored and applied for future app inits. If takeOff is called again with a different config, the new config will not be applied until the next app init.

  var config = AirshipConfig(
      defaultEnvironment: ConfigEnvironment(
          appKey: "REPLACE_WITH_YOUR_APP_KEY",
          appSecret: "REPLACE_WITH_YOUR_APP_SECRET"
      ),
      site: Site.us, // use eu for EU cloud projects
      urlAllowList: ["*"],
      androidConfig: AndroidConfig(
          notificationConfig: AndroidNotificationConfig(
              icon: "ic_notification",
              accentColor: "#00ff00"
          )
      )
  );

  Airship.takeOff(config);

URL Allowlist

The URL allowlist controls which URLs the Airship SDK is able to act on. The SDK divides up usages of URLs into three different config options:

  • urlAllowListScopeOpenUrl: Only URLs allowed for this scope can be opened from an action, displayed in landing page, displayed in an HTML in-app message, or displayed as media in an In-App Automation. Defaults to any Airship-originated URLs and YouTube URLs.
  • urlAllowListScopeJavaScriptInterface: These URLs are checked before the Airship JavaScript interface is injected into the webview. Defaults to any Airship-originated URLs
  • urlAllowList: Both scopes are applied to these URLs.
Valid URL pattern syntax
<pattern> := '*' | <scheme>'://'<host>/<path> | <scheme>'://'<host> | <scheme>':/'<path> | <scheme>':///'<path>
<scheme> := <any char combination, '*' are treated as wild cards>
<host> := '*' | '*.'<any char combination except '/' and '*'> | <any char combination except '/' and '*'>
<path> := <any char combination, '*' are treated as wild cards>

To accept any URL within the SDK, set the urlAllowList to ["*"].

Implementation best practices

Make sure to set up logging. Internal logging can be valuable when troubleshooting issues that arise when testing.

Anytime you make any changes or updates to the SDK, test on a development device to ensure your integration was successful. Also make sure analytic information is still flowing to your Airship project before sending the app to production.