fechanique / cordova-plugin-fcm

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

onNotification not called in iOS #544

Open joemak93 opened 5 years ago

joemak93 commented 5 years ago

The plugin works perfectly on Android, but I found the onNotification not called in iOS. it can get the FCM token, the push message arrived the phone in both foreground and background, but when click the message, the onNotification not called. here is my code:

            this.fcm.onNotification().subscribe(data => {
              if(data.wasTapped){
                    console.log("Received in background = "+ JSON.stringify(data));
              } else {
                 console.log("Received in foreground = "+ JSON.stringify(data));
              };
            });

I'm using cordova-plugin-fcm-with-dependecy-updated 2.2.4

githubkyo commented 5 years ago

onNotification not fire.

nissarcs commented 5 years ago

The plugin works perfectly on Android, but I found the onNotification not called in iOS. it can get the FCM token, the push message arrived the phone in both foreground and background, but when click the message, the onNotification not called. here is my code:

            this.fcm.onNotification().subscribe(data => {
              if(data.wasTapped){
                  console.log("Received in background = "+ JSON.stringify(data));
              } else {
                 console.log("Received in foreground = "+ JSON.stringify(data));
              };
            });

I'm using cordova-plugin-fcm-with-dependecy-updated 2.2.4

Hi Did you find solution . i couldnot able to figure out even added APNS in firebase console .onNotification is not firing

jffs commented 5 years ago

same here

jffs commented 5 years ago

As I also had localNotification plugin, i don't know the reason but, onNotification() never fired. I removed it and works as i expected. Instead of using a local notification, I display an alert.

aagaardmorten commented 5 years ago

I had simular problem in a long time. I have solved my problem. IOS: I getthe token, but I dont get pushed notifications despite they reach the mobilephones notification tray. My solution - actually quite simple:

The FCMPlugin.onNotification should be declared AFTER the device is ready: addeventlistner...deviceready.

document.addEventListner("deviceready",onDeviceReady,false); function onDeviceReady(){ FCMPlugin.onNotification(function(data){..... }

john-doherty commented 5 years ago

Anyone get this working?

john-doherty commented 5 years ago

Quick update: I got this working by skipping the demo project and setting up my own node service using https://github.com/smartnav/fcm-notification.

nitishbhardwaj1111 commented 4 years ago

Hi @joemak93, @jffs, @githubkyo i tried and able to navigate to other pages on clicking on notification. as i saw your code and found that the ios console does not store the previous consoles, as android console do. So you are not able to see the console. you please show any toast, or navigate to any other page can see the demo code. i just showed a toast.

this.platform.ready().then(() => {
        this.fcm.onNotification().subscribe(data => {
          if (data.wasTapped) {
            this.apiService.showSuccess("Notification clicked");
          }
        });
    });
abdulahad-07 commented 4 years ago

As I also had localNotification plugin, i don't know the reason but, onNotification() never fired. I removed it and works as i expected. Instead of using a local notification, I display an alert.

This worked for me.