question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting Duplicate Notifications (tested on Android)

See original GitHub issue

Hi,

I’m getting duplicate notifications on Android (haven’t tested ios). My code is quite simple since I’m just starting out:

export default class NotificationService {
    static initHandler() {
      FCM.on(FCMEvent.Notification, async (notification) => this._handleNotification(notification));
    }
    static _handleNotification(notification) {
      console.log("Got " + notification.messageId);
    }
}

and in App.js

NotificationService.initHandler();
export const App = StackNavigator({
  Login: {screen: Login}
});

When I push a message from the backend service I get the same alert on the phone multiple times. I also keep getting previous alerts. The backend is not the problem. I checked that the backend is sending each notification once and I have the same app implemented 100% in Kotlin which works perfectly.

I’m fairly certain that I’m not registering multiple handlers since I checked that initHandler() is only called once. I’m very new to RN, am I doing something wrong or is there a known issue?

  • versions: “react-native-fcm”: “^11.0.2” and “react-native”: “0.51.0”,
  • Device: Samsung S8, Android 7.0
  • This happens no matter what the app state is, foreground, background or stopped (cleared from task list).

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
abhaykumar1415commented, Mar 23, 2019

I had to remove <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

from AndroidManifest.xml

1reaction
ivanfranchicommented, Nov 29, 2019

I was getting duplicated notifications because of developing 2 apps with the same package name.
Both the applications were receiving the Notification

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicated Notifications - OneSignal Documentation
Usually duplicate notifications occur due to sending the same push data multiple times. If you see multiple notifications sent in your Delivery Tab...
Read more >
Getting duplicate push notifications : r/Android - Reddit
Push notifications come in through Google C2DM mechanism. When I was developing my messaging app I was getting duplicate intents.
Read more >
Android received duplicate push notifications (onesignal)
1 Answer 1 ... Usually duplicate notifications occur due to sending the same push data multiple times. If you see multiple notifications sent...
Read more >
Stop duplicate chat notifications - Android - Google Chat Help
On your mobile device, open Settings. Tap Apps and notifications and then Chat and then App notifications. Make sure that app notifications are...
Read more >
Duplicated notifications in Android - Salesforce Stack Exchange
when I send a push in firebase console theres a problem of duplicated notifications, because etpushsdk uses gcm and my application fcm. I'm ......
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