React-native-push-notification: How to dismiss notification on user action?

Created on 29 Jan 2020  路  1Comment  路  Source: zo0r/react-native-push-notification

I have added actions to my app's notifications using this workaround. However, when I press on any action, the notification remains there. I would like it to go away. Is there any way to do it?

Most helpful comment

Okay, I have found a way to make it work. Adding the line PushNotification.clearLocalNotification(id) dismisses the notification when an action is tapped. Like this:

PushNotification.configure({
    onNotification: notification => {
                . . . 
        PushNotification.clearLocalNotification(notification.id)
    },
    . . .
})

>All comments

Okay, I have found a way to make it work. Adding the line PushNotification.clearLocalNotification(id) dismisses the notification when an action is tapped. Like this:

PushNotification.configure({
    onNotification: notification => {
                . . . 
        PushNotification.clearLocalNotification(notification.id)
    },
    . . .
})
Was this page helpful?
0 / 5 - 0 ratings