evollu / evollu/react-native-fcm

Clear all notifications in the android notification tray

Open
#1,119 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.7k
Forks
661
PR merge metrics
No merged PRs in 30d

Description

I'm sending multiple notifications to my app. What I want to achieve is whenever a user clicks one notification then all notifications in the notification tray disspear.

I've tried adding

`notification.android.setAutoCancel(true)`

which does the trick for only one notification (the one which is being clicked)

I've also tried:

`firebase.notifications().removeAllDeliveredNotifications() `

which doesn't have any effect.

How can I achieve this?

Here's my full code:

componentDidMount() {
firebase.notifications().removeAllDeliveredNotifications()

this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
});

this.notificationListener = firebase.notifications().onNotification(async (notification) => {
// Process your notification as required
notification.android.setAutoCancel(true)
firebase.notifications().removeAllDeliveredNotifications()
}
async componentWillMount() {
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
});
this.notificationListener = firebase.notifications().onNotification((notification) => {
});

this.notificationDisplayedListener();
this.notificationListener();
}`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the notification flow around firebase.notifications().onNotification and the calls to notification.android.setAutoCancel(true) and removeAllDeliveredNotifications(). Confirm the expected behavior on Android: clicking one notification should clear every delivered notification, and verify whether the current API calls produce that result.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, firebase, javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.