Send a notification message to a specific websockets using a user token (targeting by unique key of token). The notification is sent to all websockets opened with the same user token.
| webntf | Websocket service called via API |
| send.to.token | Action called on remote API |
| domain | Target domain name for notifications |
| target | Target user token (key) for notifications |
| message | Notification message data (defined by JavaScript) |
array(3) {
["domain"]=>
string(16) "www.websocket.cz"
["target"]=>
string(16) "6ju9xnrkhh7z163md12fkek3v"
["message"]=>
array(14) {
["lang"]=>
string(2) "en"
["title"]=>
string(27) "Test websocket notification"
["body"]=>
string(39) "Notification sent 16.3. 2022 at 23:06:44"
}
}
$responseData = $rest2WebSocket->call("webntf", "send.to.token", [
"domain" => "www.websocket.cz"
, "target" => "6ju9xnrkhh7z163md12fkek3v"
, "message" => [
"lang" => "en"
, "title" => "Test websocket notification"
, "body" => "Notification sent 16.3. 2022 at 23:06:44"
]
]);
array(3) {
["status"]=>
string(2) "OK"
["time"]=>
float(1647438936.566092)
["result"]=>
int(3) // number of messages sent to client websockets
}
For more information on how to handle notifications using a javascript application, see this article.