Double notifications on Android (Always) & IOS (Sometimes)

See original GitHub issue

Followed the documentation to create a notification service extension for ios: https://notifee.app/react-native/docs/ios/remote-notification-support

Server side: I am using firebase-admin (node js) and sending message like this:

const title = "Hi"
const body = "How are you"
const data = {
          type: "CHAT",
          jobId: "1",
          title,
          body,
        };
await getMessaging().sendMulticast({
          tokens: tokenList,
          data: data as any,
          notification: {
            title,
            body,
          },
          apns: {
            payload: {
              aps: {
                contentAvailable: true,
                mutableContent: true,
                sound: 'default',
              },
              notifee_options: {
                title,
                body,
                data,
                ios: {
                  foregroundPresentationOptions: {
                    alert: true,
                    badge: true,
                    sound: true,
                  },
                },
              },
            },
          },
        });

notifications seem to be working fine on IOS (sometimes i get 2 notifications on ios as well) but on Android i am getting 2 notifications consistently when app is in the background. I am using notifee.displayNotification to display the notification in both android and ios.

I believe i am seeing 2 notifications because i am using notification option which gets displayed automatically and then setBackgroundMessageHandler handles the notification and data again and show another notification.

I can remove the notification option while sending a multicast message but then it will break the ios notification. Any suggestions will be much appreciated.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
sushilbansalcommented, May 13, 2022

i used https://notifee.app/react-native/docs/ios/remote-notification-support

The complete message that worked me is:

        const data = {
          type: "Chat",
          jobId: "1",
          title: "title",
          body: "body",
        };

        await getMessaging().sendMulticast({
          tokens: receiever.notiTokens,
          android: {
            priority: 'high',
            data: data as any,
          },
          apns: {
            payload: {
              aps: {
                contentAvailable: true,
                mutableContent: true,
                sound: 'default',
              },
              notifee_options: {
                ...data,
                ios: {
                  foregroundPresentationOptions: {
                    alert: true,
                    badge: true,
                    sound: true,
                  },
                },
              },
            },
          },
        });
2reactions
Darapsascommented, May 13, 2022

Hello there, @sushilbansal, So you have closed the issue, did you manage to solve it? I am experiencing the same thing, would be interesting to hear what worked for you

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop Messages From Ringing Twice on Your iPhone
How to Stop Messages From Pinging Twice on iPhone · First, open the Settings app on your iPhone. · Then, scroll down and...
Read more >
How to stop your iPhone from beeping twice when you get a ...
Open Settings and tap Notifications. · Scroll down through the list of apps and tap Messages. · Tap Customize Notifications. · Tap Repeat...
Read more >
Fix double notifications for Messages : r/GooglePixel - Reddit
I am receiving duplicate notifications from my Google messages app. ... It's vibrating my watch constantly for the same message.
Read more >
Solved: Receiving double notifications on some apps - 130639
I've had the same issue...multiple notifications. I solved it by finally finding where to turn it off. Go to settings then notifications. Scroll ......
Read more >
Why do I keep receiving double notificati… - Apple Community
Since you know which apps are causing the problems, first thing I would do is go to Notification center for the particular app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found