react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[🐛] Bug Report Duplicate fcm push notification in react native android backgroundhandler

Open Cazs03 opened this issue 2 years ago • 3 comments

Related to https://stackoverflow.com/questions/71507734/duplicate-fcm-push-notification-in-react-native-android-backgroundhandler

I getting duplicate notification in background

"@react-native-firebase/app": "^14.9.4",
"@react-native-firebase/messaging": "^14.9.4",

JS React Native

    messaging().onMessage(async remoteMessage => {
      console.log('onMessage: ' + JSON.stringify(remoteMessage));
    });
    messaging().setBackgroundMessageHandler(async remoteMessage => {
      console.log(
        'Message handled in the background!',
        JSON.stringify(remoteMessage),
      );
    });

NodeJS banckend

messaging
    .send({
      notification: { title: 'Price drop', body: 'ioioioio' },
      topic: 'club'
    })
    .then((response) => {
      // Response is a message ID string.
      console.log('Successfully sent message:', response);
    })

Error: image

Cazs03 avatar May 25 '22 12:05 Cazs03

Hi there! Please strip the code repro snippets down to just an index.js and App.js that do nothing but show exactly how you reproduce this problem.

Please note that if you include a notification block in the FCM you send, the firebase-android-sdk will display a notification. Period. Every time. Outside of your control. You will not be able to disable it.

So then if you also pop a notification using some other code that you are not showing, you'll get two.

Every time these have been investigated it has been a combination of that fact not being fully understand and then - with the new understanding - detecting API mis-use and altering project code.

It never results in changes in this library and is not actionable here - to set expectations

mikehardy avatar May 25 '22 14:05 mikehardy

Hello, but I did not understand you with the answer. Do you want me to reduce the code to the most basic? Or expand information with more code?

Cazs03 avatar May 25 '22 16:05 Cazs03

Both, your example right now is not complete or I do not think there would be a second notification, and I suspect it is not minimal as when I see snippets that implies a lot more code elsewhere. Both complicate triage and should be avoided when requesting help: https://stackoverflow.com/help/mcve

mikehardy avatar May 25 '22 16:05 mikehardy

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.

github-actions[bot] avatar Dec 05 '22 19:12 github-actions[bot]