Notification API -

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.

API service and action

webntfWebsocket service called via API called on remote API

API request data

domainTarget domain name for notifications
targetTarget user token (key) for notifications
messageNotification message data (defined by JavaScript)

Example request data

array(3) {
    string(16) ""
    string(16) "6ju9xnrkhh7z163md12fkek3v"
    array(14) {
        string(2) "en"
        string(27) "Test websocket notification"
        string(39) "Notification sent 16.3. 2022 at 23:06:44"

Example PHP code for call websocket API

$responseData = $rest2WebSocket->call("webntf", "", [
    "domain" => ""
    , "target" => "6ju9xnrkhh7z163md12fkek3v"
    , "message" => [
        "lang" => "en"
        , "title" => "Test websocket notification"
        , "body" => "Notification sent 16.3. 2022 at 23:06:44"

API response data

array(3) {
    string(2) "OK"
    int(3)	// number of messages sent to client websockets

Example of javascript application

For more information on how to handle notifications using a javascript application, see this article.