FCM
Provides basic functionality for Firebase Cloud Messaging
Repo: https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated $ npm install --save @ionic-native/fcm@4 - Add this plugin to your app's module
 
Supported platforms
- Android
 - iOS
 
Usage
import { FCM } from '@ionic-native/fcm';
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.unsubscribeFromTopic('marketing');
Instance Members
getToken()
Gets device’s current registration id
  Returns: Promise<string> Returns a Promise that resolves with the registration id token
onTokenRefresh()
Event firing on the token refresh
  Returns: Observable<string> Returns an Observable that notifies with the change of device’s registration id
subscribeToTopic(topic)
Subscribes you to a topic
| Param | Type | Details | 
|---|---|---|
| topic | 
      string
     | 
    
       Topic to be subscribed to  | 
  
  Returns: Promise<any> Returns a promise resolving in result of subscribing to a topic
unsubscribeFromTopic(topic)
Unsubscribes you from a topic
| Param | Type | Details | 
|---|---|---|
| topic | 
      string
     | 
    
       Topic to be unsubscribed from  | 
  
  Returns: Promise<any> Returns a promise resolving in result of unsubscribing from a topic
onNotification()
Watch for incoming notifications
  Returns: Observable<any> returns an object with data from the notification
NotificationData
| Param | Type | Details | 
|---|---|---|
| wasTapped | 
      boolean
     | 
    
       Determines whether the notification was pressed or not  |