Cordova-plugin-firebase: Push notification received twice on android

Created on 19 Oct 2016  路  9Comments  路  Source: arnesson/cordova-plugin-firebase

With this code in my cordova app, when I send a push since firebase, my app receive 2 notifications instead of 1.

var firebasePlugin = window.FirebasePlugin;

firebasePlugin.getInstanceId(function(token) {
       console.log(token);
   }, function(error) {
       console.log(error);
   });

   firebasePlugin.onNotificationOpen(function(notification) {
       console.log(notification);
   }, function(error) {
        console.log(error);
   });

Is missing something in my code ?
Thanks

All 9 comments

Hello, I'm having the same problem,more specifically the onNotificationOpen is executing twice, Log:

onNotificationOpen file.js:23
Object {} file.js:24
onNotificationOpen file.js:23
Object {}controllers.js:24

I also would like to know how to get the notification's content(title,message)? I can't find anything in that Object{}

in Android I have the same problem. In iOS the behaviour is correct

Same problem twice on android

same issue in android. onNotificationOpen() is called twice on foreground

window.FirebasePlugin.onNotificationOpen(function (notification) {
  try{
        console.log(notification);
        var item = angular.toJson(notification);
        $ionicPopup.alert({
            title: item.title,
            template: item.text;
        });
    }catch (e) {
        alert(e);
    }
},function (error) {
    console.error(error);
});

i have put a comment on below line in OnReceive method in OnNotificationOpenReciver.java and now seems the issue is sorted.

//FirebasePlugin.sendNotification(data);

fixed in 437b228c1e19518e6ec83f1c24326c04fb80adc4

I think that we don't have the same problem.
When I send a notification from firebase console or with http api, I receive the same notification twice.

Someone have the same problem ?

android_notif

Had the same issue on Android (7.1.1):

  • 1 notification if the app is in foreground
  • 2 notifications if the app is in background

No issue on iOS

Actually this happens because I'm using this plugin https://github.com/intercom/intercom-cordova. If I remove it, the notification shows once

Was this page helpful?
0 / 5 - 0 ratings