Group notifications
See original GitHub issueQuestion
Hello! How does group and groupSummary work? I recently migrated from React Native Firebase V5, to this library to handle local notifications. In RNFirebase I had to create and display 2 notifications, one that should be only for summary group and and another to handle the notification itself and asign it to the group.
In this library, the option groupSummary is present, but it isn’t seem to be working for me, or maybe I’m doing it wrong. I’m creating/displaying the notification with the code below. I want to group notifications in separated groups. Should I use two notifications, like on RNFirebase? If so, in what format should they be?
Another thing that I realized is that there is not groupAlertBehavior option, to handle a notification that will be only for the group summary.
Thanks!
PushNotification.localNotification({
/* Android Only Properties */
autoCancel: true, // (optional) default: true
largeIcon: "", // (optional) default: "ic_launcher". Use "" for no large icon.
smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher". Use "" for default small icon.
vibrate: true,
vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
tag: "approved", // (optional) add tag to message
group: "approved", // (optional) add group to message
groupSummary: true, // (optional) set this notification to be the group summary for a group of notifications, default: false
priority: "max", // (optional) set notification priority, default: high
importance: "max", // (optional) set notification importance, default: high
channelId: DEFAULT_CHANNEL_ID, // (optional) custom channelId, if the channel doesn't exist, it will be created with options passed above (importance, vibration, sound). Once the channel is created, the channel will not be update. Make sure your channelId is different if you change these options. If you have created a custom channel, it will apply options of the channel.
/* iOS and Android properties */
title: message.data.title, // (optional)
message: message.data.body, // (required)
playSound: true, // (optional) default: true
soundName: "default", // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
number: message.data.badge, // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
});
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top GitHub Comments
@FranciscoCHT I have found a better solution without the need of extra channels. Using the following code you should not need an extra channel:
Ended up following the same logic as I did with RNFirebase V5 (Android only).
I created two
PushNotification.localNotification
, one for the notification itself, and another for creating the groupSummary that will group the others notifications.The problem with this was that
onNotification
it will show 2 popup notifications at the same time (one grouped and the one arriving). In Android, this is fixed by adding the parametergroupAlertBehavior
which allows to set to silent the groupSummary notification, but it hasn’t been added to this library yet.So, since I hadn’t this parameter, and wanted only to show the arriving notification as popup, and the group notification silent, I had to create a special channel, with
PushNotification.createChannel
, and configured it to be silent, then assigned it to the groupSummary notification.Then assigned it to the 2 local notifications. The POPUP CHANNEL to the arriving notification, and the SILENT CHANNEL to the groupSummary notification.
The group summary notification has to have the same ID in each group you want to create, otherwise it will group in different notifications, and has to be a number, otherwise it’ll not work.
This should group notifications that share the same
group
parameter, and mantain silent the group notifications. I know that the creation of another channel isn’t ideal, and I don’t know if there is a simpler solution, but feel free to share any finds! 😄