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');