Method for Working with Push Notifications

To work with push notifications, execte requests using the "push" API method (define user token before request execution):

curl -X GET '<IP address or DNS server name>/api/v1/push/tokens/' --header 'Authorization: Bearer <user token>' --header 'Accept: application/json'

Example of response:

{

  "received_date":"2020-10-30T10:58:04.414637Z",

  "device":{

    "id_string":"654654ghdfg5435",

    "is_active":true,

    "os_version":"iOS"},

  "token":"b34735aa4681cfe91616c775f3b9b8f7f410a3e7c79ed6a48dfd41907a13be23",

  "push_service":"Firebase"

}

curl -X POST '<IP address DNS server name>/api/v1/push/tokens/add/' --header 'Authorization: Bearer <user token>' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"token": {"service": "<service name>", "platform": "<platform type>", "value": "<token>"}}'

Example of response:

{

  "status":"OK"

}

curl -X POST '<IP address or DNS server name>/api/v1/push/tokens/remove/' --header 'Authorization: Bearer <user token>' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"tokens": ["<token>"]}'

Example of response:

{

  "status":"OK"

}

curl -X GET '<IP address or DNS server name>/api/v1/push/topics/' --header 'Authorization: Bearer <user token>' --header 'Accept: application/json'

Example of response:

[

  {

    "name":"topic",

    "description":"",

    "subscribed":true

  },{

    "name":"topic1",

    "description":"",

    "subscribed":false

  },{

    "name":"topic2",

    "description":"",

    "subscribed":false

  }

]

curl -X POST '<IP address or DNS server name>/api/v1/push/topics/subscribe/' --header 'Authorization: Bearer <user token>' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"topics":["<topic name 1>","<topic name 2>",...,"<topic name n>"]}'

Example of response:

{

  "status":"OK"

}

curl -X POST '<IP address or DNS server name>/api/v1/push/topics/unsubscribe/' --header 'Authorization: Bearer <user token>' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"topics":["<topic name 1>","<topic name 2>",...,"<topic name n>"]}'

Example of response:

{

  "status":"OK"

}

curl -X POST '<IP address or DNS server name>/api/v1/push/send/<template name>/user/<user name>/' --header 'Authorization: Bearer <user token>' --header 'Accept: application/json' -d '{"text" : "text","body": "body"}'

Example of response:

{

  "status":"OK"

}

curl -X POST '<IP address or DNS server name>/api/v1/push/send/<template name>/topic/<topic name>/' --header 'Authorization: Bearer <user token>' --header 'Accept: application/json' -d '{"text" : "text","body": "body"}'

Example of response:

{

  "status":"OK"

}

See also:

Server API | Setting Up Push Notifications