0

I am doing Push notification message in android devices and follows GCM documentation for my reference and I have scenario that in the notification itself I have to show buttons and user clicked it will trigger the respective actions.

From the GCM documentation, in the notification payload we can add click_action to trigger the action when user touched notification...

How to show buttons (Like Accept/Reject ) in the notification message?

PrabaharanKathiresan
  • 1,099
  • 2
  • 17
  • 32
  • Let me tell you a suggetion. Now Google is using Firebase Cloud Messaging and they have a lot of tutorials to run every kind of functions (push notification, social network login, cloud database, etc.) I really recommend it :-) https://firebase.google.com/docs/ – David Corral Aug 12 '16 at 13:22

2 Answers2

2

You can use .addAction in Notification.Builder.

Notification notification = new Notification.Builder(context)
    // Show controls on lock screen even when user hides sensitive content.
    .setVisibility(Notification.VISIBILITY_PUBLIC)
    .setSmallIcon(R.drawable.ic_stat_player)
    // Add media control buttons that invoke intents in your media service
    .addAction(R.drawable.ic_accept, "Accept", prevPendingIntent) // #0
    .addAction(R.drawable.ic_reject, "Reject", pausePendingIntent)  // #1

// Apply the media style template

EDIT 1

Refer this link.

Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
0

There is no way to add action buttons to a notification message. This may be a feature added later on but currently it does not exist.

Notification messages allow you to create a very specific type of notification, if you want to have a very custom notification then you should use data messages (not notification messages) and then when the message is received use the Notification.Builder to generate your custom notification with as many features as are available :)

Arthur Thompson
  • 9,087
  • 4
  • 29
  • 33