invertase / notifee

⚛️ A feature rich notifications library for React Native.
https://notifee.app
Apache License 2.0
1.88k stars 228 forks source link

Android : cancelNotification didn't work. #938

Closed momolly1024 closed 10 months ago

momolly1024 commented 11 months ago

As I use this code, cancelNotification didn't work. and sure id is correct

messaging().setBackgroundMessageHandler(async (remoteMessage) => {
    try {
        // const notifications = await notifee.getNotifications()
        const n = await notifee.getDisplayedNotifications()
        console.log(n.length)
        if (n.length >= 2) {
            await notifee.cancelNotification(n[0].id)
            console.log(n[0].id)
        }
    } catch (error) {
        console.error('Error handling notification in the background:', error)
    }
})
LOG like:
[{"date": "1703062421829", "id": "0", "notification": {"android": [Object], "body": "test", "id": "0", "title": "2"}}, {"date": "1703062418195", "id": "0", "notification": {"android": [Object], "body": "test", "id": "0", "title": "1"}}]

I am using FCM and notifee.

Did I miss something or setting error?

Thank you.

github-actions[bot] commented 10 months ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.