Add action to fire base notification

I am trying to add an action button for notifications created on firebase 9.0.0 for Android when the application is in the background .

Any ideas?

Thank!!

+4
source share
4 answers

So, to set up notifications when the application is in the background, as Diego noted, the only way is to create a notification yourself. Adding the "data" key to the notification payload results in the onMessageReceived () callback, on which you can create any notification and notify about it.

Thing is, Firebase, API. . API .

+1

firebase-cloud-messaging API .

firebase: https://firebase.google.com/support/contact/bugs-features/

data-message API onMessageReceived() .

+5

, , ( , ), background, :

final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.addAction(
                    R.drawable.ic_setting_light,
                    res.getString(**R.string.Your_Button_String**),
                    PendingIntent.getActivity(
                            context,
                            0,
                            **Your_Intent_To_Open_When_Button_Is_Click**,
                            PendingIntent.FLAG_UPDATE_CURRENT));

, Android.

. Android 4.1 .

0

All Articles