Install & Setup the Flutter Plugin
Learn how to install the Airship Flutter plugin, configure iOS and Android platforms, and initialize the SDK.
This guide walks you through installing the Airship Flutter plugin and configuring it for both iOS and Android platforms.
Requirements
- Flutter 3.0.2 or higher
- iOS 15+ (Xcode 16+)
- Android API 23+
Install the plugin
Add the Airship dependency to your package’s
pubspec.yamlfile:dependencies: airship_flutter: ^flutterPluginVersionInstall your Flutter package dependencies by running the following in the command line at your project’s root directory:
flutter pub getImport Airship into your Dart code:
import 'package:airship_flutter/airship_flutter.dart';
Initialize Airship
The Airship SDK requires a single entry point called takeOff to initialize. Call takeOff in your app’s main() function before running the app. This ensures Airship is ready before any widgets are built.
Get your app credentials
Before calling takeOff, you’ll need your app credentials from the Airship dashboard:
- Log in to the Airship dashboard
- Navigate to Settings → APIs & Integrations → App Keys
- Copy your App Key and App Secret
Airship provides separate credentials for development and production environments. The SDK automatically selects the correct credentials based on your build configuration. However, Flutter doesn’t have a built-in way to detect this, so you can use the inProduction flag or configure based on build mode.
Configure takeOff
The following example shows how to configure and call takeOff in your Flutter app:
import 'package:flutter/material.dart';
import 'package:airship_flutter/airship_flutter.dart';
void main() {
// Ensure Flutter is initialized
WidgetsFlutterBinding.ensureInitialized();
// Configure Airship
var config = AirshipConfig(
// Development environment credentials
defaultEnvironment: ConfigEnvironment(
appKey: "YOUR_DEVELOPMENT_APP_KEY",
appSecret: "YOUR_DEVELOPMENT_APP_SECRET"
),
// Production environment credentials (optional but recommended)
productionEnvironment: ConfigEnvironment(
appKey: "YOUR_PRODUCTION_APP_KEY",
appSecret: "YOUR_PRODUCTION_APP_SECRET"
),
// Set to true for production builds
inProduction: false, // Set to true for production or use const bool.fromEnvironment('dart.vm.product')
// Cloud site: Site.us for US, Site.eu for EU
site: Site.us
);
// Initialize Airship
Airship.takeOff(config);
// Run your app
runApp(MyApp());
}Configuration options
Key configuration options include:
- defaultEnvironment: Credentials for your development/staging environment
- productionEnvironment: Credentials for your production environment (optional but recommended)
- inProduction: Set to
truefor production builds,falsefor development. You can useconst bool.fromEnvironment('dart.vm.product')to automatically detect release builds - site: Set to
Site.usfor US cloud projects orSite.eufor EU cloud projects
For additional configuration options (such as URL allowlists), see Advanced Configuration.
Once takeOff is called, the config is stored and applied for future app sessions. If you call takeOff again with a different config, the new config will not take effect until the next app restart.
Test the integration
After completing the setup, verify your integration to ensure everything is working correctly.
Build and run your app on both iOS and Android (if applicable):
flutter runCheck the console logs for Airship initialization:
- Look for log messages indicating successful SDK initialization
- You should see a Channel ID in the logs—this is the unique identifier for the device
Example log output:
Airship takeOff succeeded Channel ID: 01234567-89ab-cdef-0123-456789abcdefVerify in the Airship dashboard:
- Log in to your Airship dashboard
- Navigate to Audience → Channels
- Search for the Channel ID from your logs
- The channel should appear with the correct platform (iOS or Android)
If you don’t see a channel ID or encounter errors during initialization, see the Troubleshooting guide for common problems and solutions.
Next steps
Now that you’ve successfully integrated the Airship SDK:
- Enable push notifications and configure notification handling
- Identify users with contacts and named users
- Set up Message Center for persistent messaging
- Configure analytics to track user behavior
Categories