Skip to main content
Version: v5

FCM

Provides basic functionality for Firebase Cloud Messaging

github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation

$ npm install cordova-plugin-fcm-with-dependecy-updated $ npm install @awesome-cordova-plugins/fcm $ ionic cap sync

Supported Platforms

  • Android
  • iOS

Capacitor

Not Compatible

Usage

React

Learn more about using Ionic Native components in React

Angular

import { FCM } from '@awesome-cordova-plugins/fcm/ngx';

constructor(private fcm: FCM) {}

...

this.fcm.subscribeToTopic('marketing');

this.fcm.getToken().then(token => {
backend.registerToken(token);
});

this.fcm.onNotification().subscribe(data => {
if(data.wasTapped){
console.log("Received in background");
} else {
console.log("Received in foreground");
};
});

this.fcm.onTokenRefresh().subscribe(token => {
backend.registerToken(token);
});

this.fcm.hasPermission().then(hasPermission => {
if (hasPermission) {
console.log("Has permission!");
}
})

this.fcm.clearAllNotifications();

this.fcm.unsubscribeFromTopic('marketing');