ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
488 stars 567 forks source link

Capacitor push notification optional data payload not geting while using getDeliveredNotifications() if app killed #2128

Open kiranraj1430 opened 1 month ago

kiranraj1430 commented 1 month ago

Feature Request

Plugin

Capacitor push notification

Description

Actually, i am created a component to list received notifications from firebase in my app but the issue is, if app is opened or active I got payload response and with data{id:"OPTIONAL"} but when the app is killed or removed from background means I got push notification but I need to get payload if user reopened a app, so I used getDeliveredNotifications() but that gives

{ "notifications": [ { "id": 0, "tag": "FCM-Notification:4734679279", "title": "TEST ", "body": "TEST1", "groupSummary": false, "data": { "android.title": "TEST", "android.template": "android.app.Notification$BigTextStyle", "android.text": "TEST1", "androidx.core.app.extra.COMPAT_TEMPLATE": "androidx.core.app.NotificationCompat$BigTextStyle", "android.bigText": "TEST1"    }     }   ] }

BUT I AM SENDING THIS PAYLOAD "message": { "topic": "MADURAI", "notification": { "title": "TEST", "body": "TEST1" }, "data": { "id": "Mario", "others": "PortugalVSDenmark"     }   } }

Why I can't get this optional payload when app is killed ? "data": { "id": "Mario", "others": "PortugalVSDenmark"     }

also have some issues while compile app in android studio: error log:

image

Platform(s)

Need a background handle when app is killed

Preferred Solution

I don't know the solution, I just need to store a received fcm message payload in local storage and need to list in notification-list component but when the app is killed "data": { "id": "Mario", "others": "PortugalVSDenmark"     } not coming when calling getDeliveredNotifications(). so need a solution for that please.

Morstis commented 4 weeks ago

Probably related to: https://github.com/ionic-team/capacitor-plugins/issues/1302