Group notifications

Author: FranciscoCHTCreated Aug 11, 2020Updated Jan 10, 2025

Question

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)
});

Source: zo0r/react-native-push-notification