Search docs/
Getting StartedPlugins

FCM

Provides basic functionality for Firebase Cloud Messaging

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

Stuck on a Cordova issue?

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.

Contact Us Today!

Installation

ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updatednpm install @ionic-native/fcmnpm install cordova-plugin-fcm-with-dependecy-updatednpm install @ionic-native/fcmionic cap sync
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us

Supported Platforms

  • Android
  • iOS

Capacitor

Not compatible

Usage

React

See here.

Angular

import { FCM } from '@ionic-native/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');