Does anyone now, how you can trigger the on.notification handler on Android, when the app is closed?
I use Firebase Cloud Messaging and here is the message that I send:
'message': {
'data': {"data": data},
'android': {
'priority': "high",
'data': {
"androidData": data,
'content-available': '1'
}
}
}
As you can see I’m sending silet notifications.
And here is my code in the app:
initPush() {
console.log("Init push!");
this.options = this.initPushOptions();
this.pushObject = this.push.init(this.options);
this.pushObject.on('notification').subscribe((notification: any) => {
console.log('Received a notification', notification);
if(this.platform.is('ios')) {
this.handleIOSNotification(notification, this.pushObject);
} else if(this.platform.is('android')) {
this.handleAndroidNotification(notification);
}
});
this.pushObject.on('registration').subscribe(
(registration: any) => {
console.log('Device registered', registration);
this.appDataProv.keepOrUpdateFcmToken(
registration.registrationId
).then(() => {
console.log(
`Updated Fcm Token: ${registration.registrationId}`
);
}).catch(err => console.log(err));
}
);
this.pushObject.on('error').subscribe(
error => console.error('Error with Push plugin', error)
);
}
On Android the on notification only gets called, when the app is running, but not when the app is closed… Does anyone know how what you should do to trigger this when the app is closed?