fechanique / cordova-plugin-fcm

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

Token never received, and onNotification never triggered #617

Open Zerokk opened 4 years ago

Zerokk commented 4 years ago

I managed to install the plugin (the fork with all dependencies included), and it can receive notifications that I send from the Firebase console, or this one: https://cordova-plugin-fcm.appspot.com/

These notifications actually show up in my phone, so that's something. But when I try fetching a token, both with .getToken() or .onTokenRefresh(), nothing gets returned:

this.fcm.onTokenRefresh().subscribe(token => { console.log("token received: ", token) user.set("FCMToken", token) user.save() .then(() => console.log("[PushHandler] Token saved in Parse's User")) .catch(err => console.log("[PushHandler] Error saving FCM token")); });

Also, when I click on a notification, the app opens up, but nothing shows up. This is my handler:

    this.fcm.onNotification().subscribe(data => {
      console.log("RECEIVED MESSAGE")
      if (data.wasTapped) {
        // User tapped in the push notification
        console.log("User tapped, data", data)
        alert(data);

      } else {
        // User did not tap; is it needed to notify him anyways?
        console.log("User did not tap, data", data)
        alert(data)
      }
    });

What's wrong here?

freescout-helpdesk commented 4 years ago

Exactly the same issue. Did you find a solution?

Ahmed-Abdelftah commented 4 years ago

The same issue here any one can help ?

freescout-helpdesk commented 4 years ago

For us it did not work in Phonegap emulator, but works in the real app.

Ahmed-Abdelftah commented 4 years ago

For us it did not work in Phonegap emulator, but works in the real app.

I am trying in real device and i can get token but "onNotification" event never triggered, i am listening in app component's constructor when platform is ready , here is my code

this.platform.ready().then(() => { this.fcm.onNotification().subscribe(notificationData => { alert(notificationData); }); });

do you have any idea about what is wrong here?

ghost commented 4 years ago

@Ahmed-Abdelfattah-MF Did you find a solution since?

trung-pham commented 3 years ago

any solution for this issue?