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

feat: Support for Action Buttons in Push Notifications Plugin

Open fromage9747 opened this issue 4 years ago • 13 comments

Feature Request

Support for Action Buttons in Push Notifications Plugin.

Description

Whilst Local Notifications can produce the Action Buttons, it is a workaround, and it relies on the ability of "PushNotifications.addListener( 'pushNotificationReceived'" to run in the background, which it does not. "pushNotificationReceived" only fires when the app is in the foreground.

Platform(s)

[x ] Android [x ] iOS [ x] web

Preferred Solution

Just like how LocalNotifications has the registerActionTypes Method, Push Notifications should have the same.

PushNotifications.registerActionTypes({ types: [ { id: 'alert', actions: [ { id: 'read', title: 'Mark as Read' }, { id: 'archive', title: 'Archive Alert', destructive: true }, { id: 'delete', title: 'Delete Alert', destructive: true } ] } ] });

Alternatives

I have looked into triggering the action types via LocalNotificaitons but it does not produce the desired effect as "pushNotificationReceived" does not trigger when the app is running in the background. it only triggers when the app is running in the foreground.

Additional Context

this was closed when it shouldn't have been: https://github.com/ionic-team/capacitor/issues/1938 "pushNotificationReceived" issues: https://github.com/ionic-team/capacitor/issues/1928#issuecomment-767127172 https://github.com/ionic-team/capacitor-plugins/issues/200

fromage9747 avatar Jan 26 '21 07:01 fromage9747

bump; did the triage happen at all? 😄 may we please know the outcome, if any?

danbirle avatar Jul 27 '21 21:07 danbirle

End of 2021, Any update ?? This is important (:

shanike avatar Dec 24 '21 12:12 shanike

End of 2020, Any update ?? This is important (:

you mean 2021*?

danbirle avatar Dec 27 '21 12:12 danbirle

He's been in quarantine so long he didn't realize that another year had rolled by.

fromage9747 avatar Dec 27 '21 12:12 fromage9747

End of 2020, Any update ?? This is important (:

you mean 2021*?

Thanks lol

He's been in quarantine so long he didn't realize that another year had rolled by.

She* 😊

shanike avatar Dec 27 '21 12:12 shanike

2022 and still no solution ?

riderx avatar Mar 30 '22 21:03 riderx

+1

MohsinJamadar09 avatar Jun 13 '22 11:06 MohsinJamadar09

+1

JustDoItSascha avatar Jul 21 '22 08:07 JustDoItSascha

@JustDoItSascha as I would of course like this I have figured out why there is no work being done on it. Normal push notifications can been configured to be sent only as data so there is no popup notification. Now with this data only notification, it also works in the background, or I have read it does in documentation. So when the data is received, you can then launch a local notification which has action buttons.

I am currently in the process of implementing this as the normal push notifications module from ionic does not have the ability to refresh a token. Mine just expired. Die to this I am moving to firebase messaging which has delete token and get token in order to refresh the token.

I will then be moving forward with the local notifications and action buttons.

fromage9747 avatar Jul 21 '22 08:07 fromage9747

@fromage9747 I think that even "only data" push notifications are not working in the background, but I'm absolutely willing to be convinced it does ;-)

I would be happy if you could post when you're 100% sure that data only push will be handled when the app is closed?

JustDoItSascha avatar Jul 21 '22 08:07 JustDoItSascha

@JustDoItSascha Well, I finished implementing this and am very disappointed. The data-only push does not trigger anything when the app is in the background and there is no way of getting action buttons implemented when sending it via the payload. Every search result I have checked and tried to implement has not worked.

Foreground notifications work with Local Notifications but not the background, I have had to add the Notification payload to at least receive a notification. This is such a PITA. Trying to look into writing Android native code to see if I can get the action buttons.

My PWA side of things works perfectly though with action buttons as well. All handled by the service worker

fromage9747 avatar Sep 25 '22 04:09 fromage9747

@fromage9747 Just to ask, have you tried third-party providers like OneSignal? Would they work?

terryjiang2020 avatar Nov 02 '22 23:11 terryjiang2020

+1

typefox09 avatar Jul 03 '23 09:07 typefox09