Sending a notification to all devices
Request
To send a notification to all the devices, send a POST request to:
http://<host>:<port>/messaging/v1/topics/GlobalTopicForAllDevices/inbox
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 – base64-encoded opaque data or UTF-8-encoded data with no CR/LFs
Note that this is client-specific. For ION clients, the message must be in this format (but with CR/LFs removed):CODE{ "data" : "{ "title":"Titles promotions message", "message":"Content promotions messages" }" "notification" : "{ "title":"Titles promotions message", "message":"Content promotions messages" }" }
The contents ofdata
andnotification
must be the same.
Example
A request with this payload sends a message to all devices:
{
"envelope": {
"event": "subscription-changed",
"id": "e7ebbd43-62d3-4962-b71d-0e9f98555d9b",
"app_id": 1234,
"from": "account-management-service",
"expiration": 60000
},
"message": "eyAiZnJvbSIgOiAicmVtb3RlcHZyIiwgInRvIiA6ICIxMjM0NTYiLCAidGltZXN0YW1wIiA6ICIxNDgzNzY4OTg3IiwgInByaW9yaXR5IiA6ICIxMCIsICJyZXBseS10byIgOiAiaHR0cHM6Ly9hZGRyZXNzLnRvLnJlcGx5IG9yIG5vZGVAbWFjaGluZTpxdWV1ZSIsICJkYXRhIiA6ICJwcml2YXRlIGRhdGEgdXNlZCBieSB0aGUgZGV2aWNlIHJlbW90ZSBib29raW5nIGFwcGxpY2F0aW9uIn0="
}
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 DMM API documentation.