Skip to main content

awesome_notifications_airship 1.0.0-dev.10 copy "awesome_notifications_airship: ^1.0.0-dev.10" to clipboard
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 #

Awesome Notifications

Flutter Discord

Open Source Love pub package Full tests workflow codecov badge

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, and airship_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_channel in 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.extender replaces this one in the manifest (tools:replace="android:value") and calls AwesomeAirship.install(context) in its onAirshipReady.
  • 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).

  1. In Xcode, File β€Ί New β€Ί Target β€Ί Notification Service Extension (for example NotificationService), deployment target iOS 16. Don't activate its scheme.

  2. 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 (run flutter build ios once first so the folder exists), then the AwesomeNotificationsAirshipExtension product.

  3. Replace the generated NotificationService.swift:

    import AwesomeNotificationsAirshipExtension
    
    class NotificationService: AwesomeAirshipServiceExtension {}
    
  4. Add the same App Group to the Runner and the extension (Signing & Capabilities), and its name under the key AwnAppGroupName in both Info.plist files: the extension and the app share the core's events and the package's state through it.

  5. 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, conversation and call (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 / ios hold per-platform overrides.
  • Events: createdSource is Local (the core has no Airship source yet) and createdLifeCycle is the app's state (Terminated on iOS, where the extension can't know it). Airship's keys stay in payload: the send id (com.urbanairship.push.PUSH_ID on Android, _ on iOS) and com.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, and airship_flutter's onPushReceived still 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 buttonKeyInput has 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 onNotificationResponse still 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 with firebase_messaging. Airship receives its Android pushes through its own Firebase messaging service. Android delivers each push to one messaging service only: the one of awesome_notifications_fcm (or of firebase_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_chat and the other add-ons: the pushes are rebuilt through the same builder chain as local notifications; register the add-ons of the extension in registerAddOns().

πŸ”„ Migrating from airship_flutter alone #

  1. Add awesome_notifications and this package; keep your airship_flutter code.
  2. Create the core's channels; on Android send notification_channel with one of their keys.
  3. Move your notification handling to the core's listeners (onActionReceivedMethod, …) if you want its features; your Airship.push.onNotificationResponse and deep link handlers keep working as before.
  4. On iOS, add the Notification Service Extension (above) and send pushes with mutable content.
  5. Remove awesome_notifications_fcm or firebase_messaging if 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 #

0
likes
150
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Airship pushes built and shown by awesome_notifications (layouts, channels, buttons, events), next to the official airship_flutter plugin.

License

Apache-2.0 (license)

Dependencies

airship_flutter, awesome_notifications, flutter

More

Packages that depend on awesome_notifications_airship

Packages that implement awesome_notifications_airship