Hello everyone, I’m new to ionic and I needed to customize FCM plugin onMessageReceived() to do something under certain condition. When I build my app nothing new happens.
My question is there a way to do so (customize/edit plugin to my app preference)?
Am I missing anything?
Thanks.
Implement your FCM plugin on app.component.ts.

Thanks for your quick reply. But I don’t understand how to implement my plugin in the app.component.ts. Can you please illustrate more?
setTimeout(() => {
this.pushsetup();
}, 1000);
pushsetup() {
if (!this.platform.is('cordova')) {
console.warn('Push notifications not initialized. Cordova is not available - Run in physical device');
return;
}
const options: PushOptions = {
android: {
senderID: ''
icon: 'icon_push'
},
ios: {
alert: 'true',
badge: true,
sound: 'true'
},
windows: {}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) => {
if (notification.additionalData.foreground) {
//console.log(notification.message);
}
});
pushObject.on('registration').subscribe((registration: any) => {
//do whatever you want with the registration ID
let type_device = 'no_device';
if(this.platform.is('android')){
type_device = 'android';
} else if(this.platform.is('ios')){
type_device = 'ios';
}
let registertoken = {
push_token : registration.registrationId,
type_device: type_device
}
this.storage.set(' ', registertoken);
});
pushObject.on('error').subscribe(error => console.log('Error with Push plugin' + error));
}