OpenTV ENTera & OpenTV Platform Documentation

Sending a message to all devices

Request

To send a message to all the registered devices, send a POST request to:

http://<host>:<port>/messaging/v1/topics/GlobalTopicForAllDevices/inbox

In some cases, if the message includes a notification section and is received while the client application is not open, the system shows the notification and the message never makes it to the client.

In this case, you may need to send the message twice – once with a notification and once without.

Headers

  • Content-Type: application/json

Mandatory fields

  • topic_name (in URL) – this is the default topic, GlobalTopicForAllDevices, to which all devices are subscribed automatically.

  • envelope object containing at least:

    • from – who the notification is from

  • message – the message – a string or JSON converted to a string (that is, with line breaks removed and special characters escaped).
    See Message format – general notifications for a detailed explanation of the expected message format.
    Within message:

    • Include a notification block if the notification is meant to be presented immediately to the user.

    • Omit the notification block if the client should store the notification so that the user can view it when they choose to (for example, in an inbox).

If you choose to use the recommended message schema (see Message formats), you can also include the following in a message:

  • An image or video to be included in the message

  • An action to be performed if the user clicks on the message (e.g., open a product, tune to a channel, etc.)

  • A display time for the message

  • A priority level for the message

  • Additional values for referenceType: NOTIFICATION, ALERT, and PROMOTION

Note that these fields rely on the client application being updated to make use of them.

If you use ION as your client application, it does not yet recognise these fields.

Example

A request with this payload sends a message to all devices:

JSON
{
  "envelope": {
    "from": "Operator"
  },
  "message":"{
    "notification": {
      "body": "20% off all TVOD until Sunday",
      "title": "Discount Movies"
    },
    "data": {
      "body": "20% off all TVOD until Sunday",
      "title": "Discount Movies",
      "referenceType": "NOTIFICATION_UPDATE" 
    }
  }"
}

Note that "message" in the JSON above is shown with line breaks and is unescaped for clarity. In reality, you must remove all line breaks and escape all relevant characters within "message".

The JSON that you would actually use as the body of the request is:

JSON
{
  "envelope": {
    "from": "Operator"
  },
  "message":"{\"notification\":{\"body\":\"20% off all TVOD until Sunday\",\"title\":\"Discount Movies\"},\"data\":{\"body\":\"20% off all TVOD until Sunday\",\"title\":\"Discount Movies\",\"referenceType\":\"NOTIFICATION_UPDATE\"}}"
}

Response

The request returns an HTTP 200 status if the message was sent successfully.

An unsuccessful request returns an HTTP 404 status.

See also

For full details of this API, see the Device Messaging Manager (DMM) API documentation v1.