Payload examples

Examples of a typical JSON payload used for iOS and Android devices

Basic Action Object

'notification-action':

{
  "type": "{{type}}",
  "value": "{{value}}"
}
  • {{type}} of action can be anything, predefined action types include 'dial' and 'url'

  • {{value}} is dependent on type of action, when type is 'dial' then value is a phone number to be dialed, when the type is 'url' then the value is the url that is to be viewed, when the type is 'rich' then the value is the rich content id to be displayed, when the type is anything else, it is handled by the plugin defined for that type.

📘

Note:

User could define their own custom action type and value.

{
  "category-actions": {
    "name": "Navigate To URL",
    "type": "navigateTo",
    "value": "Error! Hyperlink reference not valid.",
    "foreground": true,
    "authentication": true,
    "destructive": false
  }
}

📘

Note:

iOS contains three extra values from Android which are: destructive, authentication and foreground which are only required when the type is not “url” “openApp”, “rich” or “dial”. Additionally, in “category-actions” the “name” field is required for the title of the button, in “notification-action” the name field is not used as it is part of the Apple payload in {“aps”:”alert”:{“action-loc-key”: “name” }}

Examples:

  • Default action example: { “type”: “url”, “name”: “url”, “value”: “http://www.google.com” }

  • User defined action (a.k.a custom action): { “type”: “snooze”, “name”: “Snooze”, “value”: “3” }

📘

Note:

For default actions the values “type”, “name” and “value” are required. For user defined actions only the “type” and “name” is required and the action object could contain user defined key/value pair.

For example if the user want to create a custom action called “add-to-cal” then this is an example payload:

{
  "type": "add-to-cal",
  "value": "Add To Calendar",
  "date": "8/8/2024",
  "recipients": [
    "[email protected]",
    "[email protected]"
  ]
}

Example of the key date and recipients being user defined.

Date - ISO-18601- date as a String

Payload example in iOS

{
  "aps": {
    "content-available": 1
  },
  "dynamic-aps": {
    "alert": "Bob wants to play poker",
    "badge": 5
  },
  "notification-action": {
    "type": "{{type}}",
    "value": "{{value}}"
  },
  "category-actions": [
    {
      "name": "{{name}}",
      "type": "{{type}}",
      "value": "{{value}}",
      "destructive": "{{destructive}}",
      "authentication": "{{authentication}}",
      "foreground": "{{foreground}}"
    },
    {
      "name": "{{name}}",
      "type": "{{type}}",
      "value": "{{value}}",
      "destructive": "{{destructive}}",
      "authentication": "{{authentication}}",
      "foreground": "{{foreground}}"
    }
  ]
}

Payload example in Android

{
  "alert": {
    "subject": "my subject",
    "message": "my message",
    "notification-action": {
      "type": "openApp",
      "value": {
        "variable1": "value1",
        "variable2": "value2"
      }
    },
    "expandable": {
      "type": "text",
      "value": "This is a very long text that I used for demonstrating Android’s BigText style. Because this is an expandable notification, all the text is displayed.",
      "expandable-actions": [
        {
          "type": "url",
          "name": "url",
          "value": "http://www.google.com”"
        },
        {
          "type": "snooze",
          "name": "Snooze",
          "value": "3"
        },
        {
          "type": "dial",
          "name": "phone",
          "value": "0509473828"
        }
      ]
    }
  }
}

Default Action JSON Validations

Default action JSONs are validated for JSON parsing errors only.