Skip to content

Push Notification Events

For developers

Push token subscription and interaction events, with endpoint and payload internals. Business meaning: Event Catalog. Receive/open lifecycle: Popups, Search and Push.

Overview

Before you start make sure that you sync your firebase project with segmentify. If you think you’ve not done it yet, please check this documentation.

Push integration uses dedicated push endpoints instead of /add/events/v1.json.

Static methods on Events:

  • Events.subscribePushNotification({ token, providerType? })
  • Events.pushNotificationInteraction({ type, instanceId? })

Token subscription

Method

Events.subscribePushNotification({ token, providerType? })

Parameter details

  • Required token
  • Optional providerType (FIREBASE or APNS)

Runtime payload behavior

SDK sends:

  • type: 'PERMISSION_INFO'
  • providerType: 'FIREBASE' by default
  • providerType: 'APNS' when device is iOS and config.apnsEnabled is true
  • deviceToken
  • userId (from SDK user storage)
  • os (uppercased platform)

Endpoint

{segmentifyPushUrl}/native/subscription/push?apiKey={apiKey}

Push interaction events

Method

Events.pushNotificationInteraction({ type: 'VIEW' | 'CLICK', instanceId? })

Runtime payload behavior

SDK sends:

  • instanceId (defaults to empty string)
  • userId
  • os
  • type

Endpoint

{segmentifyPushUrl}/native/interaction/notification?apiKey={apiKey}

Repository usage

  • example/src/services/PushService.ts:
    • sends VIEW on notification-received callback
    • sends CLICK on notification-response callback
    • retries token registration in app layer
  • example/src/App.tsx (Event Playground):
    • initializes PushService and listeners after mount when not running in Expo Go
    • Push Subscribe button: reads FCM token from PushService, then Events.subscribePushNotification({ token })
    • Push Interaction VIEW / CLICK buttons: call Events.pushNotificationInteraction(...) with demo instanceId values for API inspection

Deep Linking

  • Deep linking needs few actions to be done before sending push notification events. Your product urls given in the product feed must be mapped for android and ios if you’re not using universal links.
  • Universal links are supported. By default you’ll receive notification response as below:
{
"messageId": "1776869279156910",
"from": "283543040560",
"data": {
"redirectUrl": "https://www.xyz.com/shoe/adidas-superstar-white-black?utm_source=segmentify&utm_campaign=psh_e2167ff68a000&utm_content=static&utm_medium=push&_sgf_campaign_name=test",
"image": "https://media.segmentify.com/0108b006-c136-460e-be1e-286bcfa9affc/e5063022-40fc-473c-b7ed-85698cf5c2f2.jpg",
"message": "Test Message",
"title": "Test Message",
"dataCenterUrl": "<dataCenterUrl>",
"deeplink": "yourapp://shoe/adidas-superstar-white-black",
"instanceId": "psh_e2167ff68a000",
"fcm_options": {
"image": "https://media.segmentify.com/0108b006-c136-460e-be1e-286bcfa9affc/e5063022-40fc-473c-b7ed-85698cf5c2f2.jpg"
},
"apiKey": "0108b006-c136-460e-be1e-286bcfa9affc"
},
"notification": {
"body": "Test Message",
"sound": "default",
"title": "Test Message"
},
"mutableContent": true,
"category": "segmentify"
}
  • Deep link is the url that you’ll receive in the notification response. You can use this url to navigate to the appropriate screen in your app.
  • Instance ID is the id of the push notification campaign. You will need this to send push interaction events.

You’ll need to configure your app to handle deep linking. Firebase kill, background, foreground handlers will help you to handle deep linking.

Notes

Requesting push notification from firebase sdk is your responsibility. Segmentify SDK only manages token registration and interaction events. Still you’ll receive push notification events from Segmentify SDK. But you’ll need to request push notification permission from firebase sdk.

Checklist for Push Notifications

  • Make sure that you’ve sync your firebase project with segmentify.
  • Make sure that you’ve configured your app to handle deep linking. (If you want to use deep linking)
  • Request push notification permission from firebase sdk.
  • Register token with Segmentify SDK.
  • Listen to push notification events from Segmentify SDK.
  • Send push interaction events to Segmentify SDK.

Example

import { Events } from '@segmentify/react-native-v2';
// Register token with Segmentify SDK.
Events.subscribePushNotification({ token });
//In Firebase listener callback send
//Push Interaction CLICK
Events.pushNotificationInteraction({ type: 'CLICK', instanceId });
// Push Interaction VIEW
Events.pushNotificationInteraction({ type: 'VIEW', instanceId });