custom interactive notification in Android

Hi All,

 

I have been trying to create the custom interactive notification, I have given the below code after UAirship.takeoff

// Define actions for the group
NotificationActionButton hiButtonAction = new NotificationActionButton.Builder("PAY_CATEGORY")
.setLabel(R.string.pay_category)
.setIcon(R.drawable.your_icon_file)
.setPerformsInForeground(true)
.build();

NotificationActionButton byeButtonAction = new NotificationActionButton.Builder("bye")
.setLabel(R.string.bye)
.setIcon(R.drawable.your_icon_file)
.setPerformsInForeground(true)
.build();

// Define the group
NotificationActionButtonGroup buttonGroup = new NotificationActionButtonGroup.Builder()
.addNotificationActionButton(hiButtonAction)
.addNotificationActionButton(byeButtonAction)
.build();

// Add the custom group
airship.getPushManager().addNotificationActionButtonGroup("custom group", buttonGroup);

 

But i am not able to get any interactive buttons, i am able to get only notification

 

The server side i have been sending following format 

{
   "audience": {
        "android_channel": "047108b1-ab55-41e5-8e32-4ca4b8da6e5e"
    },
    "device_types":["android"],
    "notification": {
        "android": {
            "alert": "Hello1",
            "interactive": {
      "type": "PAY_CATEGORY",
      "button_actions": {
         "PAY_IDENTIFIER": {
            "add_tag": "more_cake_please",
            "remove_tag": "lollipop",
            "open": {
               "type": "url",
               "content": "http://www.urbanairship.com"
            }
         }
      }
   }
        }
    }
    
}

Didn't find what you were looking for?

New post

Comments

6 comments

  • Hi Jagadesh,

    For your code, you'll want to ensure that the resources that the Notification Builder is using are all present within your app.

    Specifically:

    R.string.bye

    R.drawable.your_icon_file

    R.string.pay_category

    Make sure the above are defined within your app. Otherwise, we won't be able to know where to pull those resource files from.

     

    Secondly, you'll want to make some changes to your API request.

    The Interactive Notification type that you have set up is not called "Pay_Category". Instead, in your code, you have it defined as "custom group". You'll want to make sure you're using the correct value for the "type" field. Additionally, since you have two buttons defined for your custom interactive notification, you'll want to define the actions for that button within your API request.

    Comment actions Permalink
    0
  • Thank you it worked for me 

    Comment actions Permalink
    0
  • is possible to send custom interactive with big_picture (android case) ?

    Comment actions Permalink
    0
  • Marcello,

    Yes, this would be possible. Big Picture is sent in a different field (The "Style" field) that is separate from the Interactive Notification.

    Comment actions Permalink
    0
  • Tks Michael, after long long time reading documentation and trying we found a solution and include deeplink features.

     

    Comment actions Permalink
    0
  • Good to hear!

    Comment actions Permalink
    0

Please sign in to leave a comment.