Interactive Notifications are a great way to let the user interact with your app without having to open it.

Sailthru Mobile supports sending to both iOS and Android to activate Interactive Notifications.

On iOS

On iOS, interactive notifications are configured via the UIUserNotificationSettings, UIUserNotificationCategory, UIUserNotificationAction classes, and their mutable counterparts.

On a UIUserNotificationCategory, an identifier property is set, which a push payload should include to activate this, plus any other relevant data.

On iOS, use the startEngine overload and call startEngine:registerForPushNotifications: with a NO value. Then register with your own types and settings.


iOS 10 Support

If you're supporting iOS 10 notifications, the structure of the payload does not change, however the classes you use natively will. The above classes have been deprecated in favor for those prefixed with UN (eg UNNotificationSettings, UNNotificationCategory, UNNotificationAction).

On Android

Actions can be pre-defined for push notifications using the addAction() method. Actions are grouped by a "category" attribute that is sent as a part of the push bundle. When a notification arrives that contains a matching category attribute, the push data is injected into the action's intent and attached to the notification.

//This Intent must explicitly define an Activity, Service, or BroadcastReceiver class.
Intent actionIntent = new Intent(this, MyBroadcastReceiver.class);
NotificationConfig config = new NotificationConfig();
        "category",                       // Action Category
        R.drawable.ic_action_reply,       // Action Icon
        "Reply",                          // Action Text
        actionIntent,                     // Intent that is fired upon tap. 
        PendingIntent.FLAG_UPDATE_CURRENT // PendingIntent Flags

To add more Actions to a category, call addAction() for each action and set them all to the same category.


NotificationConfig#addAction(String, int, CharSequence, Intent, RemoteInput, int)

AddAction() has an optional RemoteInput parameter that allows for user input to be included in the data that is sent. See RemoteInput in the Android Documentation for more information, and see Direct Reply For how to handle inline replies.

Responding to Actions

Inside the bundle that is sent to the intent defined in addAction() is a valued called "_nid". The hashcode of _nid is the identifier for the notification in the system tray.

public void onReceive(Context context, Intent intent) {
    String notificationId = intent.getStringExtra("_nid");

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

Another option is to use getActiveNotifications() to get a reference to update the notification.

Sending a push

Once the category is defined and hard-coded by a developer, the key category can be used in both the Sailthru Mobile Dashboard, Notifications, and Messages APIs.


Fill in the Category box to trigger your interactive notification.

API Example

Simply add the category key and value to the payload.

curl -X POST -u BUNDLE_ID:API_KEY -H "Content-type: application/json" -H 'Accept: application/json' -d '{
  "notification": {
    "to": [{ "name": "tags", "criteria": ["tag1"]}, { "name": "custom.string.mykey", "criteria": ["tag2"]}],
    "payload": {
      "alert": "This is a push notification test",
      "badge": 1,
      "sound": "Default.caf",
      "category": "TEST_CATEGORY",
      "any_key": "any_value" //Arbitary keys/values.