fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 989 forks source link

Receiving duplicate notification in random intervals #416

Open FredeHo opened 6 years ago

FredeHo commented 6 years ago

My Android Ionic app receives the same push notifications multiple times in random intervals (mostly around 3-5 minutes) for hours. But its not about the callback onNotification() being triggered multiple times - there are real notifications popping up in the statusbar. It does not matter if I use your fcm testserver or my node.js server to send the notifications. It's always the same: minutes after the "original and correct" push a duplicate is received and this repeats for a indeterminate time.

My app is using crosswalk. I've noticed that if I remove crosswalk new notifications work as expected and will only be received once. It's driving me insane and I can't find the root of the problem. Has anyone experienced this problem as well? Thanks in advance!

EDIT: Another similar app has the same setup (fcm + crosswalk) and is working fine. I don't see a difference that could lead to such a behavior tho :/

yayohack commented 6 years ago

+1

henrykalex commented 6 years ago

Same problem here

manish2535 commented 6 years ago

+1. Even if I am offline it keeps coming which tells me it's the plugin.

yayohack commented 6 years ago

Any update on this?

This is my code: `app.factory('Push',function($rootScope, $ionicPopup, $localstorage, $state){ ionic.Platform.ready(function(){ FCMPlugin.onTokenRefresh(function(token){ console.log(token) $http({ method : 'POST', url : URLcode.URLdir + "setProfile", transformRequest: transformRequestAsFormPost, data: { session_token: $localstorage.get("session_token"), token: token }, headers: {'Content-Type': 'application/x-www-form-urlencoded'} }) .success(function(data, status, headers, config) { console.log(data) }) }); FCMPlugin.subscribeToTopic('all');

FCMPlugin.onNotification(function(data){
  console.log(data)
  if(data.closeCheck){
    $rootScope.feedbackModal=true;
    $localstorage.remove("checkId");
    $localstorage.remove("establishmentId");
    $state.go("tabsHome.check");
  }
  $rootScope.$broadcast("update", {});
  if(data.wasTapped){
    if(data.message){
      $ionicPopup.alert({
        title: 'Alerta',
        template: data.message
      })
    }
  }else {
    if(data.message){
      $ionicPopup.alert({
        title: 'Alerta',
        template: data.message
      })
    }
  }
},function(data,status){
  console.log(data)
  console.log(status)
}
,function(data){
  console.log(data)
});

});`

yayohack commented 6 years ago

Solved by uninstalling plugin, updating platforms and reinstall plugin

Arxi commented 6 years ago

I also have this problem - on Android 8.0.0 (have not tested IOS), using Ionic v1. I'm using ostownsville fork though.

@FredeHo @yayohack @henrykalex @manish2535 can you post your configurations? Or have you solved the issue already? Can this be caused by LocalNotification plugin?

cordova 8.0.0 cordova-android 6.4.0

com.verso.cordova.clipboard 0.1.0 "Clipboard" cordova-plugin-android-permissions 1.0.0 "Permissions" cordova-plugin-app-event 1.2.0 "Application Events" cordova-plugin-background-mode 0.7.2 "BackgroundMode" cordova-plugin-camera 4.0.1 "Camera" cordova-plugin-console 1.0.7 "Console" cordova-plugin-device 1.1.6 "Device" cordova-plugin-fcm 3.0.3 "FCMPlugin" cordova-plugin-file 5.0.0 "File" cordova-plugin-file-opener2 2.0.19 "File Opener2" cordova-plugin-file-transfer 1.7.0 "File Transfer" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-inappbrowser 1.7.1 "InAppBrowser" cordova-plugin-ios-non-exempt-encryption 1.0.0 "ITSAppUsesNonExemptEncryption false" cordova-plugin-network-information 1.3.3 "Network Information" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-statusbar 2.3.0 "StatusBar" cordova-plugin-whitelist 1.3.2 "Whitelist" cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin" de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification" ionic-plugin-keyboard 2.2.1 "Keyboard"

jakute commented 6 years ago

@yayohack i have the same problem, how did you update platforms?

Thanks in advance

nsz0306 commented 6 years ago

hey I had the same problem. I fixed it by changing in my platforms/android/project.properties file all the com.google... lines to version 11.8.0.

jasarsoft commented 4 years ago

npm install @ionic-native/in-app-browser@4.20