Skip to main content

Push Notifications

Push notifications are messages you create in the panel and Positive User delivers to your app's users through Firebase Cloud Messaging. The SDK registers the device, counts clicks and passes the notification to your code.


What it is​

A push notification has a title, a message, an optional image and an optional link. It is delivered to a device even when your app is not running. On iOS, Firebase passes it on through Apple Push Notification service (APNs).


How it works​

Conditions​

  • The Firebase service account key is uploaded to the panel, see Setup & Configuration. For iOS, the APNs key is uploaded to Firebase, see the Firebase guide.
  • The device has sent its FCM token to Positive User with a ping.
  • The user allowed notifications for your app.

Flow​

  1. Your app gets an FCM token from Firebase and the SDK sends it to Positive User with a ping.
  2. You send a push notification campaign or an automation step from the panel.
  3. Positive User sends the notification through Firebase to the device.
  4. The operating system shows it. While your app is in the foreground, Android and Flutter show it through the SDK instead, see Platform differences.
  5. When the contact taps it, the SDK reports the click and passes the notification, including its link, to your code. When the click is counted depends on the platform, see Platform differences and Opening App Screens.

Tokens and devices​

  • A token belongs to one contact at a time. When a ping sends a token that another contact has, the token moves to the contact of that ping.
  • If a contact has several devices with tokens, a push notification goes to the device with a token that sent a ping most recently.
  • When Firebase reports a token as no longer registered, Positive User removes it.

Platform differences​

iOSAndroidFlutter
Who gets the FCM tokenYour app passes it to the SDKThe SDK gets it from FirebaseYour app passes it to the SDK
Who shows the notificationiOSThe system, when the app is in the background or closed. In the foreground, the SDK builds it, only for notifications with type 1 in the payload.The system, when the app is in the background or closed. In the foreground, buildNotification shows a banner inside your app, or your own builder handles it.
Click counted whenThe tapped notification is passed to handleNotification(userInfo:), or the SDK is the notification center delegate. Do not pass notifications from willPresent, each call counts as a clickYour launcher activity calls handleRouteFromNotification(intent)Automatically for the banner shown in your app. For a system notification, after you call notificationClickedEvent
Link on tapPassed to your RemoteNotificationDelegate. The SDK does not open it.In the intent extras of your launcher activityBanner shown in your app: passed to your onTap callback. System notification: read getPushMessage(message.data)?.link in FirebaseMessaging.onMessageOpenedApp or getInitialMessage()
ImagesNotification Service Extension with NotificationExtensionHelperShown in notifications the system shows in the background. Notifications the SDK builds in the foreground have no image.See Flutter: notifications with image

Platform guides​