Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova-plugin-fcm: Cannot find name 'FCMPlugin'

I'm trying to use FCM push notifications with my Ionic 2 app via cordova-fcm-plugin.

I've followed every tutorial and it's working fine when i send a push from the firebase console, but i want to do some stuff in my app using its functionalities and the payload, but when i try to use any method from the plugin i get a Cannot find name 'FCMPlugin' error on Visual Studio: The error I've been looking for how to use it correctly and haven't found anything, just this question: The Question

So what is the correctly way to implement and use the plugin? Is there a module? I can call it from the 'ionic-native'? I have to import it from somewhere? Just use the plugin .js file link in the index.html? Or this error is commom and in emulation/building it'll work fine?

Thanks :D

PS: I've not tryed to build it or emulate it to see what happens, going to do this now.

EDIT

Ok, so it's an error that won't let me build my app. Rly need to know how to use the plugin now.

like image 518
Gabriel Barreto Avatar asked Mar 10 '23 08:03

Gabriel Barreto


1 Answers

You have to declare the FCMPlugin variable after your imports:

import { Foo}  from  '../pages/foo/foo';
import { Bar } from  '../pages/bar/bar';
declare var FCMPlugin: any; // <---- this is the magic line
like image 181
Martijn Avatar answered Mar 19 '23 21:03

Martijn