capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Capacitor Push Plugins - coldstart parameter

Open joeldhenry opened this issue 4 years ago • 5 comments

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!

joeldhenry avatar Jan 27 '22 04:01 joeldhenry

capacitor supports data payload, data notifications call pushNotificationReceived both on foreground and in background

jcesarmobile avatar Jan 28 '22 19:01 jcesarmobile

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 pushNotificationReceived callback with all notification data
  • [x] background app gets notification with title and body
  • [x] background app notification action would trigger app to open and pushNotificationActionPerformed callback with all data
  • [x] shutdown app gets notification with title and body
  • [x] 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 avatar Feb 03 '22 00:02 joeldhenry

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.

khaojam avatar Feb 15 '22 04:02 khaojam

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.

@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(() => {
                  ......
                });
            });

joeldhenry avatar Feb 18 '22 00:02 joeldhenry

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.

khaojam avatar Feb 18 '22 03:02 khaojam