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=>{
// ==========================
})

3 Likes

its gettng me blank white screen.

use it without (privet fcm:FCM)
directly

2 Likes

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.

2 Likes

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

4 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.

i got this error while using this
import { FCM } from “cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”;
core.js:4197 ERROR NullInjectorError: R3InjectorError(AppModule)[FCM → FCM → FCM]:
NullInjectorError: No provider for FCM!
at NullInjector.get (http://localhost:8100/vendor.js:38014:27)
at R3Injector.get (http://localhost:8100/vendor.js:48181:33)
at R3Injector.get (http://localhost:8100/vendor.js:48181:33)
at R3Injector.get (http://localhost:8100/vendor.js:48181:33)
at NgModuleRef$1.get (http://localhost:8100/vendor.js:61298:33)
at Object.get (http://localhost:8100/vendor.js:59201:35)
at getOrCreateInjectable (http://localhost:8100/vendor.js:41020:39)
at ɵɵdirectiveInject (http://localhost:8100/vendor.js:50852:12)
at NodeInjectorFactory.AppComponent_Factory [as factory] (ng:///AppComponent/ɵfac.js:6:7)
at getNodeInjectable (http://localhost:8100/vendor.js:41128:44)

you need import FCM to app.module.ts

actulay iam import fcm in app.module.ts page in providers section but its not working

so there is problem in this way in ios so ifix it by using another plugin its

----> firebasex plugin

1 Like

need help, i followed the steps above but has this error after running it,

ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘getToken’ of undefined
TypeError: Cannot read property ‘getToken’ of undefined
at FCM.push…/node_modules/cordova-plugin-fcm-with-dependecy-updated/ionic/ngx/FCM.js.FCM.getToken (/vendor-es2015.js:114568)
at AppComponent. (/main-es2015.js:1364)
at Generator.next ()
at fulfilled (/polyfills-es2015.js:5551)
at ZoneDelegate.invoke (/polyfills-es2015.js:6047)
at Object.onInvoke (/vendor-es2015.js:70734)
at ZoneDelegate.invoke (/polyfills-es2015.js:6046)
at Zone.run (/polyfills-es2015.js:5812)
at /polyfills-es2015.js:6543
at ZoneDelegate.invokeTask (/polyfills-es2015.js:6079)
at resolvePromise (/polyfills-es2015.js:6485)
at /polyfills-es2015.js:6395
at fulfilled (/polyfills-es2015.js:5551)
at ZoneDelegate.invoke (/polyfills-es2015.js:6047)
at Object.onInvoke (/vendor-es2015.js:70734)
at ZoneDelegate.invoke (/polyfills-es2015.js:6046)
at Zone.run (/polyfills-es2015.js:5812)
at /polyfills-es2015.js:6543
at ZoneDelegate.invokeTask (/polyfills-es2015.js:6079)
at Object.onInvokeTask (/vendor-es2015.js:70715)

did i miss something ? here’s my project ionic info

Ionic:

Ionic CLI : 5.4.1
Ionic Framework : @ionic/angular 4.9.1
@angular-devkit/build-angular : 0.803.24
@angular-devkit/schematics : 8.2.2
@angular/cli : 8.3.5
@ionic/angular-toolkit : 2.0.0

Capacitor:

Capacitor CLI : 1.2.1
@capacitor/core : 1.2.1

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.1, (and 22 other plugins)

Utility:

cordova-res : 0.15.3
native-run : 1.3.0

System:

NodeJS : v14.16.0 (D:\Node JS\node.exe)
npm : 6.14.8
OS : Windows 10

firebasex plugin use it

1 Like

i tried firebasex but can’t seem to work, i think it’s because of my version. i solved it by using OneSignal Push Notifications Instead