Capacitor Push Plugins - coldstart parameter
Feature Request
Plugin
Push Plugin
Description
in cordova, the phonegap-push-plugin and later supported cordova-push-plugin have functionality for data payload notifications and coldstart parameter for actions when app is not open during push action.
capacitor plugin only supports notification payload in background, and both notification and data payload must be provided in foreground, otherwise you do not get the message in the callback.
Platform(s)
Android ios
Preferred Solution
Capacitor push plugin should have support for data payload the same as cordova/ionic imeplementaiton.
Alternatives
Provide an example of the required service to extend this functionality.
Additional Context
Upgrading from Cordova to capacitor and the main reason is to get away from Cordova push plugin!
capacitor supports data payload, data notifications call pushNotificationReceived both on foreground and in background
My issues is that in Cordova, notification actions could be differentiated between being in the background or being shutdown with the coldstart flag.
following capacitor guides, i have updated our backend to send FCM data with title and body:
{
Title: "Notification Title"
Body: "Notification Body"
data: {
title: "Notification Title" // backwards compatibility with old ionic cordova app
body: "Notification Body" // backwards compatibility with old ionic cordova app
param1: “…”,
….
}
}
which gives me:
- [x] foreground app gets
pushNotificationReceivedcallback with all notification data - [x] background app gets notification with title and body
- [x] background app notification action would trigger app to open and
pushNotificationActionPerformedcallback with all data - [x] shutdown app gets notification with title and body
- [x] shutdown app notification action would trigger app to start and
pushNotificationActionPerformedcallback with all data
however these is no way to determine if the action was triggered in when app was shutdown or just in the background
Hi @joeldhenry ,
I've placed the pushNotificationActionPerformed event listener in my app.component.ts but i didn't receive the notification data because the callback function didn't get trigger during app cold start. Mind to share how did you manage to get notification data from the pushNotificationActionPerformed callback for cold start? My project is in Angular by the way. Cheers.
Hi @joeldhenry ,
I've placed the
pushNotificationActionPerformedevent listener in myapp.component.tsbut i didn't receive the notification data because the callback function didn't get trigger during app cold start. Mind to share how did you manage to get notification data from thepushNotificationActionPerformedcallback for cold start? My project is in Angular by the way. Cheers.
@khaojam i initialised the plugin within the ngOnInit inside app.component.ts and wrapped the return function inside ngZone. but this has nothing to do with this issue though.
PushNotifications.addListener('pushNotificationActionPerformed', (notification) => {
this.zone.run(() => {
......
});
});
shutdown app notification action would trigger app to start and pushNotificationActionPerformed callback with all data however these is no way to determine if the action was triggered in when app was shutdown or just in the background
@joeldhenry you mentioned here shutdown app notification action would trigger pushNotificationActionPerformed callback but it didn't get trigger on my project, therefore, i thought i have placed the event listener at the wrong place. But what you've mentioned on above, is the same as what i'm currently have.