React-native-push-notification: Group notifications?

Created on 4 Mar 2018  路  7Comments  路  Source: zo0r/react-native-push-notification

Is there a solution for this already?

Stale

Most helpful comment

You can send a data-only notification, and pass the data to localNotification method:

PushNotification.configure({
  // (required) Called when a remote is received or opened, or local notification is opened
  onNotification: function (notification) {
    console.log("NOTIFICATION:", notification);

    if(!notification.userInteraction) {
       PushNotification.localNotification(notification.data);
    }
    else {
    // process the notification
    }

    // (required) Called when a remote is received or opened, or local notification is opened
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  },
});

You can add more condition than just passing the notification.data to localNotification, but it's a basic exemple.

All 7 comments

You can get a simple grouping done with the payload here: https://github.com/zo0r/react-native-push-notification/issues/935

But support for configuring the "group summary" and allowing multiple different groups of messages seems to be unsupported :

https://github.com/zo0r/react-native-push-notification/issues/935

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Had to remove this library completely. We're using One Signal now for push notifications and this library is great and allows you to group notifications and all.

Still, for those that have the same need, I wouldn't close this issue.

Hi @filipemerker
Group notifications are already implemented.

  group: "group", // (optional) add group to message
  groupSummary: false, // (optional) set this notification to be the group summary for a group of notifications, default: false

Regards,

Hey, @Dallas62,

That's for a localNotification tho.
How to group notifications that come from a remote server?

You can send a data-only notification, and pass the data to localNotification method:

PushNotification.configure({
  // (required) Called when a remote is received or opened, or local notification is opened
  onNotification: function (notification) {
    console.log("NOTIFICATION:", notification);

    if(!notification.userInteraction) {
       PushNotification.localNotification(notification.data);
    }
    else {
    // process the notification
    }

    // (required) Called when a remote is received or opened, or local notification is opened
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  },
});

You can add more condition than just passing the notification.data to localNotification, but it's a basic exemple.

Fair enough, thanks for the snippet, I hope it's useful for somebody in the future!

Was this page helpful?
0 / 5 - 0 ratings