Documentation > Advanced Topics

Advance Android Push Notification Options

Apart from Title and Message, you have the below mentioned options to add to your Android push notification. Please note that each of these are optional.

Image URL

If an image link is specified, a large image is added to your push notification.
Recommended resolution: 600×300
Max size: 40 kb
Supported file formats are .jpg and .png

Large icon URL

If a large icon link is specified, the large icon will be appended to the push notification. Based on the device, the large icon will be displayed either far left or far right.
Max resolution – 72×72
Max size – 1 kb

Deep link/External URL

Deep link helps you open a particular activity in your app on click of the notification. If left empty, the notification on click will open the launcher activity of the app. If you wish to use external URLs, then please whitelist the IPs or provide http/https before the URL so that they can be handled properly by the SDK.

Action buttons

You can add upto 3 call to action buttons for every push notification. For every action button, you have the following options:
– Title: contains the Call to Action text (mandatory)
– Deep link: the deep link that should open on click of that button
– Action ID: a user defined string (applicable to apps custom handling their android push notifications: This string will be available as an extra on the notification click intent for you to identify the action button clicked) This is a mandatory field.
– Icon Resource Identifier: A drawable icon in your app’s resources folder to display the icon along with the notification for Android devices below OS version Nougat. Android Nougat does not display icons by default to give more room for buttons.

If the user clicks on the main body of the notification, the app will open and the notification will disappear. If the user clicks on one of the action buttons, then by default android will not remove the notification from the tray. We provide 2 user options for this

  • Handle closing the notification yourself (applies to apps that are custom handling the push notification):
    To accomplish this, the click intent has the notification Id in its extras. So to close, please add the following code in the activity that would get called:
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String actionId = extras.getString("actionId");
        if (actionId != null) {
            Log.d("ACTION_ID", actionId);
            boolean autoCancel = extras.getBoolean("autoCancel", true);
            int notificationId = extras.getInt("notificationId", -1);
            if (autoCancel && notificationId > -1) {
                NotificationManager notifyMgr =
                        (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
                notifyMgr.cancel(notificationId);  // the bit that cancels the notification
            }
            Toast.makeText(getBaseContext(),"Action ID is: "+actionId,
                    Toast.LENGTH_SHORT).show();
        }
    }
    
    copy Copied

  • CleverTap handles closing the notification
    You will have to add an additional CleverTap IntentService to your Manifest.xml and the SDK will do it for you automatically.

    <service
         android:name="com.clevertap.android.sdk.CTNotificationIntentService">
         <intent-filter>
             <action android:name="com.clevertap.PUSH_EVENT"/>
         </intent-filter>
     </service>
    
    copy Copied

android push notification

Sound Files

You can choose to have no notification sound, the default OS sound or use a custom sound. It has to be present in the resources folder of your app. Click here for steps on how to add a sound file to your android app.
Android only supports .mp3, .ogg and .wav files.

Setting Priority

Relative priority for this notification. Priority is an indication of how much of the user’s valuable attention should be consumed by this notification.

  • MAXIMUM: Use for critical and urgent notifications that alert the user to a condition that is time-critical or needs to be resolved before they can continue with a particular task. A notification with priority set to maximum will be a heads up notification, and will always be at the top in the notification tray.

  • HIGH: Use primarily for important communication, such as message or chat events with content that is particularly interesting for the user. High-priority notifications trigger the heads-up notification display. A notification with priority set to high will be a heads up notification.

  • DEFAULT: Use for all notifications that don’t fall into any of the other priorities. A notification with default priority will simply show up in the notification tray and its order in the notification tray is subject to presence of other notifications.