2

I am using FCM Cloud Messaging framework to send and receive push messages for both Android and ios. To send messages from my server I call FCM v1 API. I use FCM SDK app in my native app (react native based) to generate device registration token, etc. I am trying to find ways where the push messages show grouped in device system tray like on Whatsapp i.e. messages containing a particular unique id should be grouped under one category e.g. all messages for a particular stock ticker showing under one group, etc. When searching for possible solutions I came across various links such as:

React Native - Android - FCM - Display group notification like What's app also allowing multiple grouped notifications

Group fcm notifications like whatsapp but allowing multiple group notifications

But none of those helped. For example sending "tag" field replaces previous message when new one is received with the same value. Moreover when app is closed none of the message handling functions of native app are executing on the device so I believe this should be purely a server side functionality. On FCM docs page there is no reference to grouping of messages.

https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages

Any suggestions on how to implement this ?

EraftYps
  • 778
  • 1
  • 6
  • 18
NKM
  • 602
  • 1
  • 6
  • 18
  • try to send 4 or more push notifications to a single device in android. does it group? – Gaurav Roy Jun 15 '20 at 10:01
  • Are you referring to app-level grouping where all app specific messages are grouped automatically ? That already happens. I need to group messages as per unique values. – NKM Jun 15 '20 at 10:23
  • @NKM did you find out a solution for it? – Deepak Verma Feb 19 '21 at 16:53
  • Nope, the grouping works only on ios but not on Android. Nothing in React Native that could help here, at least not when I tried. For ios grouping it is server side mechanism using thread-id in the push message. – NKM Feb 21 '21 at 02:40

2 Answers2

0

I implemented that with the help of the library react-native-push-notification and this issue helped me a lot Group notifications

Aman Ullah
  • 49
  • 7
0

For Android(For those who didn’t find the answer)

import PushNotification, {Importance} from 'react-native-push-notification';


PushNotification.configure({

onNotification: function (notification) {

const channelId = notification.data.channelId;

PushNotification.createChannel(
{
 channelId: channelId,
 channelName: "My channel",
 channelDescription: "A channel to categorise your notifications",
 playSound: false,
 soundName: "default",
 importance: Importance.HIGH,
 vibrate: true,
 },
 (created) => console.log(`createChannel returned '${created}'`)
 );
// Continue handling the notification

}, })

For Ios

Just Pass the threadIdentifier in the notification payload from server the APNS will automatically handle the grouping on iOS side

Hamid Ali
  • 74
  • 5