Firebase FCM: unable to get token or set up notification handlers

Hi there!

In the Ionic docs, the FCM plugin page has some quick example on how to make it work. Well, I managed to install the Cordova plugin and actually got notifications showing up in my phone (yay!), but there are two things that are messed up that don’t seem to work.

  1. I can’t get any token from .getToken() or .onTokenRefresh(). They just don’t ever return anything.
  2. When I click in a notification sent from the Firebase Console or the online notification tester they have, I see the notification, but when I click on it, my handlers do not work.

My implementation is this one:

  providedIn: 'root'
export class PushHandlerService {

    private fcm: FCM,
    private platform: Platform
  ) {


  initialize() {
    try {
      this.platform.ready().then(() => {
        console.log("Inicializando pushhandler")

        const user = Parse.User.current();
        this.fcm.onTokenRefresh().subscribe(token => {
          console.log("token received: ", token)
          user.set("FCMToken", token)

            .then(() => console.log("[PushHandler] Token saved in Parse's User"))
            .catch(err => console.log("[PushHandler] Error saving FCM token"));

  } catch(err) {
    console.log("[PushHandler] ERROR: ", err)

setHandlers() {
  console.log("Setting up handlers")
  try {
    // Subscribe to schedule reminders

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

      } else {
        // User did not tap; is it needed to notify him anyways?
        console.log("User did not tap, data", data)
    console.log("[PushNotification] Handlers set up");
  } catch (err) {
    console.log("[PushHandler] ERROR: ", err)

I also added the FCM plugin to the “providers” part in the main module.

Every other code seems to work, console.logs say so. But these two parts won’t ever work; they don’t even return any kind of message or error. What’s wrong here?

1 Like

I’m running into this same issue, did you ever figure it out??