Ionic-native firebase getToken()

ionic-native firebase getToken()
I don’t seem to get any response from getToken at all?
I even tried triggering it manually with a button.

...
import { Firebase } from '@ionic-native/firebase/ngx';
...
constructor(public firebaseNative: Firebase),
...
async getToken() {
let token;
token = await this.firebaseNative.getToken();
alert(token);
}

I get nothing back, not even an error?

successfully Installed: ionic cordova plugin add cordova-plugin-firebase
successfully Installed: npm install @ionic-native/firebase
I compiled the app on using ionic pro / app flow and installed it on a real Android device, no emulator.

What am I doing wrong please?
How can I retrieve any error messages that may be being returned by getToken() ?

@altergothen I’m also facing same problem. Can you tell me the if you resolve the issue.

Hi, I was just running on this issue few month ago.

Instead of using @ionic-native dependency, I just achieved it by this way :

App.module.ts :

import { FCMPluginOnIonic } from "cordova-plugin-fcm-with-dependecy-updated/ionic";

// Add it to providers

The class where your instanciate it :

Import :

import { FCM } from "cordova-plugin-fcm-with-dependecy-updated/ionic";

My setup method (Adapt it for yours) :

  private async setupFCM() {
    await this.platform.ready();
    if (!this.platform.is('cordova')) {
      return;
    }
    FCM.onTokenRefresh().subscribe((newToken) => {
      this.authService.firebaseToken = newToken;
    });
    FCM.onNotification().subscribe((payload) => {
      this.badge.increase(1);
      this.toastCtrl.create({
        header: payload.title,
        message: payload.body,
        position: 'top',
        buttons: [
           {
            role: 'cancel',
            icon: 'close'
          }
        ]
      }).then(toastEl => {
        toastEl.present();
     });         
    });

    this.hasPermission = await FCM.requestPushPermission();
    this.firebaseFCMToken = await FCM.getToken();
    this.authService.firebaseToken = this.firebaseFCMToken;
    this.pushPayload = await FCM.getInitialPushPayload();
  }