awesome_notifications_airship 1.0.0-dev.10
awesome_notifications_airship: ^1.0.0-dev.10 copied to clipboard
Airship pushes built and shown by awesome_notifications (layouts, channels, buttons, events), next to the official airship_flutter plugin.
awesome_notifications_airship #

Airship pushes, built and shown by awesome_notifications.
Your app keeps the official airship_flutter
plugin for everything Airship offers: take off, channel, named user, tags, in-app
automation, Message Center, preference centers. This package only changes how Airship's
pushes are shown: each one becomes a notification of the awesome_notifications core,
with its channels, layouts, buttons and events, also while the app is terminated.
Key Features: #
- One notification engine: Airship's pushes and your local notifications share the same channels, layouts, buttons and events.
- Both plugins keep their events: the core's
onActionReceivedMethod,getInitialNotificationAction, created, displayed and dismissed events, andairship_flutter's push received, notification response, deep links, Airship actions and open analytics, for the same push. Nothing to call. - Airship's payload as it is: alert, title, summary, styles, icon, color, sound, category, buttons and media attachments are mapped to the core's model.
- Awesome payload on top: a push may also carry the awesome sections (
content,actionButtons,schedule, β¦), which take priority over Airship's keys. - Every app state: on Android the SDK's notification provider is replaced; on iOS the app's Notification Service Extension rebuilds each push.
π¦ The awesome_notifications family #
Every package of the family, and where each one runs:
| Package | Push | Android | iOS | macOS | Windows | Linux | Web |
|---|---|---|---|---|---|---|---|
awesome_notifications (the core) |
π | β | β | β | π§ͺ | π§ͺ | π§ͺ |
awesome_notifications_schedules |
π | β | β | β | π§ͺ | π§ͺ | β |
awesome_notifications_localizations |
π | β | β | β | π§ͺ | π§ͺ | π§ͺ |
awesome_notifications_fcm |
β | β | β | β | β | β | π§ͺ |
awesome_notifications_wns |
β | β | β | β | π§ͺ | β | β |
awesome_notifications_unifiedpush |
β | π§ͺ | β | β | β | π§ͺ | β |
awesome_notifications_onesignal |
β | π§ͺ | π§ͺ | β | β | β | β |
awesome_notifications_braze |
β | π§ͺ | π§ͺ | β | β | β | β |
awesome_notifications_airship (this package) |
β | π§ͺ | π§ͺ | β | β | β | β |
awesome_notifications_chat |
π | β | β | β | π§ͺ | π§ͺ | π§ͺ |
awesome_notifications_media |
β | β | β | β | π§ͺ | π§ͺ | π§ͺ |
awesome_notifications_calls |
π | β | β | π§ͺ | π§ͺ | π§ͺ | π§ͺ |
awesome_notifications_live_activities |
π | β | β | π§ͺ | π§ͺ | π§ͺ | π§ͺ |
awesome_notifications_foreground_service |
β | β | β | β | β | β | β |
β supported Β· π works with push Β· π§ͺ preview (implemented, still being validated) Β· β³ planned Β· β not available on this platform
π² Installation #
dependencies:
awesome_notifications: ^1.0.0-dev.10
awesome_notifications_airship: ^1.0.0-dev.10
airship_flutter: ^13.0.0
Requirements (those of airship_flutter 13): Android minSdk 26,
iOS 16 and Swift Package Manager on iOS (airship_flutter 13 and the Airship SDK 21
dropped CocoaPods, so this package has no podspec either). airship_flutter 13 still applies
the Kotlin Gradle Plugin, so keep android.builtInKotlin=false in android/gradle.properties
(the value Flutter writes there).
π Getting started #
Set up airship_flutter as its documentation says, and initialize the core with the
channels your pushes use. Nothing else is needed in Dart:
await AwesomeNotifications().initialize(null, [
NotificationChannel(
channelKey: 'airship',
channelName: 'Airship pushes',
channelDescription: 'Messages from our campaigns',
importance: NotificationImportance.High,
),
]);
await AwesomeNotifications().setListeners(
onActionReceivedMethod: onActionReceived, // also for Airship's pushes
);
Airship.takeOff(AirshipConfig(
defaultEnvironment: ConfigEnvironment(appKey: 'β¦', appSecret: 'β¦'),
));
Airship.push.setUserNotificationsEnabled(true);
Tell an Airship push from a local notification by its payload:
if (AwesomeNotificationsAirship.isAirshipNotification(action)) { β¦ }
await AwesomeNotificationsAirship().isActive() answers whether the bridge is installed.
Android #
Nothing to do: the package declares an Airship plugin extender
(com.urbanairship.plugin.extender) in its manifest. Once Airship takes off, also when a
push starts the app, it replaces the SDK's notification provider with one that hands each
push to the core.
- The channel: a push is shown in its Airship channel
(
notification_channelin Airship's Android overrides) when the core has a channel with that key, else in the first channel created through the core. - Your own extender: an app that declares its own
com.urbanairship.plugin.extenderreplaces this one in the manifest (tools:replace="android:value") and callsAwesomeAirship.install(context)in itsonAirshipReady. - minSdk 26, as
airship_flutter.
iOS: the Notification Service Extension #
iOS shows a push before any app code runs; only a Notification Service Extension can rebuild it. Without one, Airship's pushes are shown as iOS received them (no core events, no awesome layouts or buttons).
-
In Xcode, File βΊ New βΊ Target βΊ Notification Service Extension (for example
NotificationService), deployment target iOS 16. Don't activate its scheme. -
Add the package's extension product to the new target: Frameworks and Libraries ⺠+ ⺠Add Other ⺠Add Package Dependency ⺠Add Local⦠and pick
ios/Flutter/ephemeral/Packages/.packages/awesome_notifications_airship(runflutter build iosonce first so the folder exists), then theAwesomeNotificationsAirshipExtensionproduct. -
Replace the generated
NotificationService.swift:import AwesomeNotificationsAirshipExtension class NotificationService: AwesomeAirshipServiceExtension {} -
Add the same App Group to the Runner and the extension (Signing & Capabilities), and its name under the key
AwnAppGroupNamein bothInfo.plistfiles: the extension and the app share the core's events and the package's state through it. -
In Airship, send the pushes with mutable content (Airship does it for pushes with media; enable it for the others in the iOS options, or the extension is never called).
AwesomeAirshipServiceExtension runs Airship's own service extension first
(UANotificationServiceExtension: it downloads the push's media attachment and applies its
text overrides), then rebuilds the result through the core. To give Airship's extension its
configuration, override makeAirshipExtension() and return your subclass of
UANotificationServiceExtension. To add other add-ons (chat, β¦), override
registerAddOns() and call super.
CocoaPods is not supported: airship_flutter 13 and the Airship SDK 21 are Swift
Package Manager only.
πΊοΈ The payload #
| Airship (Android data key) | Airship (iOS) | The core's model |
|---|---|---|
com.urbanairship.title |
aps.alert.title |
content.title |
com.urbanairship.push.ALERT |
aps.alert.body |
content.body |
com.urbanairship.summary |
aps.alert.subtitle |
content.summary (iOS: also shown as the subtitle) |
com.urbanairship.style big text |
content.body, notificationLayout: BigText |
|
com.urbanairship.style big picture |
com.urbanairship.media_attachment |
bigPicture, BigPicture (iOS: Airship's attachment) |
com.urbanairship.style inbox |
the lines as body, Inbox |
|
com.urbanairship.icon |
content.icon (resource://drawable/β¦) |
|
com.urbanairship.icon_color |
content.color |
|
com.urbanairship.sound |
aps.sound |
customSound (resource://raw/β¦; iOS: the push's own sound) |
com.urbanairship.visibility |
content.privacy |
|
com.urbanairship.category |
content.category |
|
com.urbanairship.notification_channel |
content.channelKey (when it is a core channel) |
|
com.urbanairship.notification_tag |
the notification id (hash of the tag) | |
aps.badge |
content.badge |
|
aps.thread-id |
content.groupKey |
|
aps.interruption-level: time-sensitive |
content.wakeUpScreen |
|
com.urbanairship.interactive_type |
aps.category |
actionButtons: the buttons of Airship's group/category, same ids and labels (foreground β Default, background β SilentAction; iOS: destructive, authentication and text input too) |
| every data key | every key but aps |
content.payload (non-text values as JSON) |
- The awesome sections win. A push may carry
content,actionButtons,schedule,localizations,conversationandcall(in Airship's extras or custom keys) as JSON objects, JSON strings or dot-flattened keys (content.title,actionButtons.0.key). They are merged over the mapped fields;android/ioshold per-platform overrides. - Events:
createdSourceisLocal(the core has no Airship source yet) andcreatedLifeCycleis the app's state (Terminatedon iOS, where the extension can't know it). Airship's keys stay inpayload: the send id (com.urbanairship.push.PUSH_IDon Android,_on iOS) andcom.urbanairship.metadata. - The notification keeps the push's original keys: on iOS in its
userInfo, on Android in its extras and in the intent that opens the app. - A push with nothing to show (no alert and no
content) is left to Airship: no notification, andairship_flutter'sonPushReceivedstill fires.
π€ Both plugins' events #
For every push this package shows, both plugins keep their events:
| Event | Android | iOS |
|---|---|---|
| Core: created / displayed | β | β (delivered when the app listens) |
Core: action (tap, button, text input), getInitialNotificationAction |
β | β |
| Core: dismissed | β | β |
airship_flutter: onPushReceived |
β | β (when the app runs, as for any push) |
airship_flutter: onNotificationResponse (tap and buttons) |
β | β |
| Airship actions (deep links, open URL, β¦) of the tap and of the buttons | β | β |
| Airship open analytics (conversion) | β | β |
| Airship button analytics (interactive notification event) | β | β for the buttons Airship knows (see below) |
How: on Android, each tap and button the core receives is also sent to Airship's own notification receiver, as Airship's notifications do (the core already opened the app, so Airship doesn't open it again). On iOS the shown notification keeps Airship's keys, and Airship's own handling of the user's response (through its app delegate integration) recognizes it; the app hands the core's button categories to Airship so that Airship keeps them registered and knows their buttons.
When only one of the two can have an event, the core's wins. What Airship loses:
- Android, a notification with
autoDismissible: false(set through the awesome sections): its taps are not reported to Airship. The core reports a user's action to add-ons when it dismisses the notification; keeping the notification means no report. - Android, a button's text input is not passed to Airship (the core's
buttonKeyInputhas it). - Dismissals are not reported to Airship on Android (Airship has no Dart event or analytics for them either). On iOS Airship sees them, with no effect.
- iOS, Airship's interactive (button) analytics and the button's "situation" need the
button's category among Airship's. The app adds the core's categories to Airship's custom
categories when it starts and each time it becomes active: a button pressed on a push that
arrived while the app was running, before the app became active again, is reported to
Airship without its button event. The button's Airship actions and
onNotificationResponsestill run. - Who opens the app: the core. On Android Airship's "open the app" of a tap is replaced by the core's (the same launch activity).
- Airship's foreground setting still decides on Android whether a push is shown while the
app is in the foreground (
com.urbanairship.foreground_display, and the plugin's foreground presentation options).
π Idempotency #
Push services deliver at least once: the same push may arrive twice. A push already received
(the same key) is not shown again on Android, and emits no created / displayed event again on
iOS (iOS shows every push the extension receives). The key is the payload's idempotencyKey
(set it in Airship's extras), else Airship's send id. The last 100 keys are kept, across
restarts.
π§© With the other push packages #
- Not with
awesome_notifications_fcm, and not withfirebase_messaging. Airship receives its Android pushes through its own Firebase messaging service. Android delivers each push to one messaging service only: the one ofawesome_notifications_fcm(or offirebase_messaging) would take Airship's pushes, and Airship would receive none. On iOS only one Notification Service Extension can run per app. Send everything through Airship. - With
awesome_notifications_chatand the other add-ons: the pushes are rebuilt through the same builder chain as local notifications; register the add-ons of the extension inregisterAddOns().
π Migrating from airship_flutter alone #
- Add
awesome_notificationsand this package; keep yourairship_fluttercode. - Create the core's channels; on Android send
notification_channelwith one of their keys. - Move your notification handling to the core's listeners (
onActionReceivedMethod, β¦) if you want its features; yourAirship.push.onNotificationResponseand deep link handlers keep working as before. - On iOS, add the Notification Service Extension (above) and send pushes with mutable content.
- Remove
awesome_notifications_fcmorfirebase_messagingif the app had them.
β Manual test checklist #
Send each push from Airship with an alert, a button group (e.g. ua_yes_no_foreground) and a
deep link, with the app in the foreground, in the background and terminated:
| Step | Expect |
|---|---|
| Push arrives | One notification (not two), in the core's channel; core created + displayed; Airship.push.onPushReceived (app running) |
| Tap | App opens; core onActionReceivedMethod (or getInitialNotificationAction when terminated); Airship.push.onNotificationResponse; Airship's deep link handler; an open in Airship's reports |
| Foreground button | Same as the tap, with the button's key; Airship's button actions |
| Background button | Core silent action; onNotificationResponse with the button id; Airship's button actions; no app opened |
| Dismiss | Core dismissed event |
Same push twice (same idempotencyKey) |
Shown once (Android) / no second created event (iOS) |
| iOS, push with media | The image is shown (Airship's extension downloaded it) |
π± Platform support #
| Feature | Android | iOS |
|---|---|---|
| Airship's pushes shown by the core (app in any state) | π§ͺ | π§ͺ (Notification Service Extension) |
| Airship's buttons | π§ͺ | π§ͺ |
| Awesome sections in the payload | π§ͺ | π§ͺ |
| Media attachments | π§ͺ (big_picture style) |
π§ͺ (Airship's extension) |
| Core events | π§ͺ | π§ͺ |
airship_flutter events, actions and analytics |
π§ͺ | π§ͺ |
| Idempotency | π§ͺ | π§ͺ |
β supported Β· π§ͺ preview (implemented, still being validated) Β· β³ planned Β· β not available on this platform
π§ How it works #
| Layer | Role |
|---|---|
| Dart | isActive() and isAirshipNotification(). Everything else is native. |
| Android | AwnAirshipPluginExtender installs AwnAirshipNotificationProvider as Airship's notification provider. Airship calls it, in every app state, for each push it would show; it builds the core's model, posts it through the core's native engine and answers CANCEL so that Airship posts nothing itself. A core hook sends each user action on an Airship push to Airship's NotificationProxyReceiver. |
| iOS | AwesomeAirshipServiceExtension (the app's Notification Service Extension) runs Airship's extension, then rebuilds the push through the core, keeping Airship's keys, attachments and sound. Airship's app delegate integration sees the user's responses. The plugin adds the core's button categories to Airship's custom categories. |
π See also #
- awesome_notifications: the notifications this package shows.
- airship_flutter: Airship's official plugin.