Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Action To Firebase Notification

I'm trying to add an action button to notifications produced on firebase 9.0.0, for Android, when app is in background.

Any ideas?

Thanks!!

like image 639
MayaB Avatar asked May 26 '16 10:05

MayaB


2 Answers

firebase-cloud-messaging doesn't provide an API to add action buttons to the notifications.

You can request new features to the firebase library here: https://firebase.google.com/support/contact/bugs-features/

For now what you can do is to send a data-message with a custom payload via the server-side API You can then receive that payload in onMessageReceived() and generate your custom notification.

like image 90
Diego Giorgini Avatar answered Oct 30 '22 04:10

Diego Giorgini


So in order to customize notifications when app is on background, as Diego mentioned, the only current way is to create the notification yourself. Adding "data" key to notification payload, results in onMessageReceived() callback, on which you can create any notification andy notify.

Thing is, I tried to send a notification from Firebase console, rather then from the API. There I couldn't add the data key properly and catch it. From API all works fine.

like image 25
MayaB Avatar answered Oct 30 '22 03:10

MayaB