7

I've been trying to group notifications by an id to have them displayed as WhatsApp for example, without having one notification per line.

Adding setGroup in either onNotification or onNotificationDisplayed seems to have no effect see examples below:

1

componentDidMount() {
this.notificationListener = firebase.notifications().onNotification(async (notification) => {
  // Process your notification as required
  notification.android.setAutoCancel(true)

  notification.android.setGroup(notification.data.channelId)
  notification.android.setGroupSummary(true)
} 
}

2

componentDidMount() {
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
   notification.android.setGroup(notification.data.channelId)
  notification.android.setGroupSummary(true)
});
}

Any idea how can I group them by id?

Rob
  • 14,746
  • 28
  • 47
  • 65
Dan Dinu
  • 32,492
  • 24
  • 78
  • 114

1 Answers1

0

how about this:-

componentDidMount() {
    var zero = firebase.notifications().onNotification((notification) => {
        this.setState({
            channelId=notification.data.channelId,
            Title=notification.data.Title,
            Body=notification.data.Body
//basically get all the data from the notification the you receieve from notification into states.
        });
    });
    if(this.state.channelId === "WhatsApp"){
        this.notificationDisplayedListener = 
            notification.android.setAutoCancel(true)
            notification.android.setTitle(this.state.Title)
            notification.android.setBody(this.state.Body)
            notification.android.setGroup(this.state.channelId)
            notification.android.setGroupSummary(true)
    }
}
  • 1
    hey, thanks for your reply but the code you've sent seems unrelated to the problem i ve described – Dan Dinu Jun 19 '19 at 20:31