Native: tried calling FCM.getToken, but the FCM plugin is not installed. ionic 5

FCM: has been created
FCMPlugin.js:26 FCM: Ready!
vendor-es2015.js:103665 Ionic Native: deviceready event fired after 1 ms
vendor-es2015.js:103970 Native: tried calling FCM.getToken, but the FCM plugin is not installed.
pluginWarn @ vendor-es2015.js:103970
vendor-es2015.js:103976 Install the FCM plugin: ‘ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated’
???
its not given me the token
any help?

ok so i fix it by using this code
import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic”;
with out (privet fcm:FCM)
fcm.gettoken().then(re=>{

})

2 Likes

Hello, I have a similar problem, I cannot get the token.

image

use this

cordova plugin add cordova-plugin-androidx-adapter
cordova plugin add cordova-plugin-androidx

and then
import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic”;

to get token
FCM.gettoken().then(re=>{
// ==========================
})

2 Likes

its gettng me blank white screen.

use it without (privet fcm:FCM)
directly

1 Like

yes, I use with out it.
its give me token,
But still can’t get notification from Firebase console on that token.

import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”;

private fcm: FCM,

it’s working fine.

1 Like

It is not working in prod mode release.

we always use ionic cordova build android for android build.

can u take photo to see what happening there

After create .apk file with command and installed on mobile. It just display blank white screen only and not move to login or home page. If you want I can send you blank white screen from mobile.

yes you are totally right

in app.module.ts

import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”;
providers: [

FCM,

],

in app.component.ts

import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”;

private fcm: FCM,

this.fcm.onNotification().subscribe(data => {

     console.log(data);

    if (data.wasTapped) {

      console.log('Received in background');

    } else {

      console.log('Received in foreground');

    }

  });

thank you so much

3 Likes

I’m unable to import in the app.module using import { FCM } from ‘cordova-plugin-fcm-with-dependecy-updated/ionic/ngx’;

I am able to get the token but this is in Develop mode and the poster said that it won’t work in prod. So I followed your comment and I can get the token but I can’t import into module.