Swan SDK
Concepts

Push architecture

How a campaign reaches a device — from the dashboard, through FCM/APNs, into your app, and back as a delivery / click ACK.

A Swan push notification is a round trip: campaign → FCM/APNs → device → user tap → click ACK back to Swan. The SDK is responsible for the last two legs.

End-to-end flow

   ┌────────────────────┐
   │  Campaigns engine  │  (you author the message + audience here)
   └────────┬───────────┘
            │
            ▼
   ┌────────────────────┐
   │   Swan backend     │  resolves audience → device tokens
   │                    │
   │   POST to FCM      │  one request per device
   └────────┬───────────┘
            │
   ┌────────▼───────────┐
   │  FCM / APNs        │
   └────────┬───────────┘
            │  data-only payload
            ▼
   ┌────────────────────┐
   │   Swan SDK         │  - receives payload in messaging service / delegate
   │                    │  - renders notification (basic or carousel)
   │   (your app)       │  - posts to OS notification tray
   │                    │  - on tap: routes to deep-link handler
   └────────┬───────────┘
            │  POST /events { type: "push_clicked", messageId }
            ▼
   ┌────────────────────┐
   │  Swan backend      │  click ACK reconciles with delivery report
   └────────────────────┘

Why data-only payloads

The SDK uses data-only FCM payloads (no notification block), which means:

  • The OS always wakes the app to handle the message — the SDK renders the notification itself
  • Background message handlers fire reliably (including for silent: 'true' payloads where we suppress the user-visible notification entirely)
  • The SDK can render carousel templates, custom sounds, and channel-specific styling that pure notification payloads can't express

The trade-off: you must keep the SDK's messaging service registered. The Android getting-started guide covers the manifest entries.

iOS pushes also go through Firebase Cloud Messaging, addressed to the device's Firebase registration token. Alongside the Swan data keys they carry an APNs alert with mutable-content: 1, so iOS displays the notification and your Notification Service Extension adds images and carousels. See the iOS push payload reference for every key. The Android and Web payloads are in the same reference.

Notification channels (Android)

The SDK declares five default channels at first init:

Channel IDImportanceUse
swan_transactionalHighOrder confirmations, OTPs
swan_alertsHighService alerts, account changes
swan_promotionalDefaultMarketing campaigns
swan_generalDefaultCatch-all
swan_notificationsDefaultLegacy / unspecified

The campaign payload picks the channel by ID. Host apps can register additional channels (e.g. one per category) via Swan.createNotificationChannel(...) — typically used for custom-sound channels, since the sound is bound to the channel at creation.

Delivery acknowledgement

When the SDK displays a notification, it reports the delivery back to Swan, so Swan can count how many devices received it. You don't wire this up: on Android the SDK's built-in push service reports every notification it displays exactly once, including when the app was closed when the push arrived. On iOS the Notification Service Extension reports it (see iOS extensions). A silent push is reported as delivered only.

Click acknowledgement

When the user taps a notification, the SDK posts a push_clicked event back to /events with the originating messageId. The campaigns engine reconciles this with its delivery report to compute open rates, attribution, and trigger follow-on journeys (e.g. "if user clicked promo X, send promo Y after 24h").

You don't wire this up — the SDK does it automatically when the notification is tapped. You only need to handle the deep-link payload via Swan.addNotificationOpenedListener and Swan.addDeepLinkOpenedListener.

Missed-push recovery (Android)

When Swan has turned recovery on for a push integration, the Android SDK and the React Native SDK on Android ask Swan for pushes the phone never received — when the app opens and every few hours in the background — and show each one once while it is still valid. Every push, original or recovered, is recorded on the phone before it is shown, so the same push is never shown twice. See Recover missed pushes.

Silent push

A payload with silent: 'true' fires the background message handler without posting a user-visible notification. The SDK reports it as delivered and never as tapped — there is no notification to tap.

Use silent push for: cache invalidation, lightweight refresh nudges, or triggering an in-app action without bothering the user.

On this page