Action Buttons

Android SDK allows you to put clickable buttons under the notification.

Requirements

  • Android SDK 2.0.0+

Before you start, if you need to handle action buttons with yourself, then you need to set your receiver in androidmanifest.xml which extends from com.dengage.sdk.NotificationReceiver. Otherwise the SDK will handle button clicks.

you need to define your receiver in your manifest file.

<receiver android:name=".MyReceiver"  
  android:exported="false">  <!-- change NotificationReceiver to .MyReceiver -->   
 <intent-filter> 
 ...
 <action android:name="com.dengage.push.intent.ACTION_CLICK" /> <!-- add this line-->   
 </intent-filter>
 </receiver>

The SDK fires an event callback which is called onActionClick in your receiver class when an action button is clicked. So you can catch the button.

public class MyReceiver extends NotificationReceiver {  
    @Override  
  protected void onActionClick(Context context, Intent intent) {  
        Bundle extras = intent.getExtras();  
		if(extras != null)  
        {  
             String actionId = extras.getString("id");  
			 int notificationId = extras.getInt("notificationId");  
			 String targetUrl = extras.getString("targetUrl");  
  
			 Log.d("DenPush", actionId +" is clicked");  
		}  
  
       // Remove if you prefer to handle targetUrl which is actually correspond a deeplink.  
	   super.onActionClick(context, intent);  
  }  
}