Interactivie Notification with custom button in Androi

In  status bar all notification displaying with the custom button. When i click first notification button then the relevant activity is opening(Not on issue). But if click another notification button from the status bar the relevant activity not opening. Please check the below code with notification button function

protected boolean onNotificationOpened(@NonNull Context context, @NonNull NotificationInfo notificationInfo, @NonNull ActionButtonInfo actionButtonInfo) {

    Log.i(TAG, "Notification action button opened. Button ID: " + actionButtonInfo.getButtonId() + ". NotificationId: " + notificationInfo.getNotificationId());

    Toast.makeText(context.getApplicationContext(),"Button Click",Toast.LENGTH_LONG).show();

    Log.e("@@@@@@@ID", String.valueOf(notificationInfo.getNotificationId()));

    Log.e("$$", String.valueOf(notificationInfo.getMessage().getAlert()));

    Log.e("eGSSSHKJHSHJS", (String) notificationInfo.getMessage().getPushBundle().get("AlarmJson"));

    String pushjson=(String) notificationInfo.getMessage().getPushBundle().get("AlarmJson");

    if(actionButtonInfo.getButtonId()!=null && actionButtonInfo.getButtonId().equalsIgnoreCase("Graph")) {

        Log.e("Graph","You clicked Graph");

        Toast.makeText(context.getApplicationContext(),"Graph Click",Toast.LENGTH_LONG).show();

        Intent i = new Intent(context.getApplicationContext(), ResultActivity.class);

        i.putExtra("From", "from@@#graphicViewRoute");

        i.putExtra("Pushjson","json@@"+pushjson);        

i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

        i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        context.startActivity(i);

return true;

}

else if(actionButtonInfo.getButtonId()!=null && actionButtonInfo.getButtonId().equalsIgnoreCase("DD"))

{

Log.e("DD","You clicked DD");

Intent i = new Intent(context.getApplicationContext(), ResultActivity.class);

i.putExtra("From", "from@@#ddviewRoute");

i.putExtra("Pushjson","json@@"+pushjson);

i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity(i);

return true;

 

}

 

// Return false here to allow Urban Airship to auto launch the launcher

// activity for foreground notification action buttons

return false;

}

 

 

Didn't find what you were looking for?

New post

Comments

5 comments

  • Hi Shanmugapriya,

    The way you'll want to accomplish this is going to be using two things:

    1. Deep-Linking

    2. Custom Interactive Notifications.

    With Deep-Linking, you are able to determine, when you compose a new push notification from Urban Airship, where you would like to direct the user in the app. 

    In conjunction with that, you are also able to define your own Custom Interactive button pairs that will deep-link the user to where ever in the app you would like to take them. Again, this is determined in the push itself, and not within the app.

    So, to support this, you'll want to scrap what work you've performed in the Airship Receiver thus far, and instead read through the following:

    1. Android Deep-Linking

    This will take you through the proper steps to set up deep-linking in your Android app, such that you will be able to direct the user to the appropriate page in your app.

    2. Custom Interactive Notification buttons

    Setting up your own button pairing will ensure that you have your own button pairings. 

    Once you have those two things set up, the push itself will determine where you deep-link the user to. This is determined by the Action that you set within the push itself. The action will specify which page to deep-link the user to, and you can specify which action you would like to associate to the buttons in the notification that you have set up previously.

    Comment actions Permalink
    0
  • Hi!

    My app's made in Ionic, and I use UA Cordova. 

    I use a custom template and custom button for deep link. seems that deep link is working, but notification is not closing.

    Do you know what can cause the issue?

    This is a link: 

    <a
    href='uairship://run-basic-actions?deep_link_action=ctustudentint://link?Type=Contacts'
    class='button'>
    View Assignment</a>

     

    Thanks!

    Comment actions Permalink
    0
  • Hi OGolovkova!,

    We see you submitted another post with the same question, so we'll answer you in that thread.

    Comment actions Permalink
    0
  • Hi,

    How to navigate from push notification and inApp notification buttons to (Deeplink) ionic app specific page.

    How i need to set/make URL, Please help me on this.

    I cant import UA cordova plugin into components.

    i have registered and mentioned in .html page.

     

    Regards,

    Mahadeva Reddy

    Comment actions Permalink
    0
  • Hi Mahadeva,

    For Cordova, I would recommend setting up an Event Listener on the Deeplink event. This will allow you to pick up deeplinks events and allow you to navigate to the appropriate area in your app.

    Comment actions Permalink
    0

Please sign in to leave a comment.