MQTT Notifications
Managing notifications.
As a developer, in some cases, you need to send real-time notifications to users following events or actions according to your application logic. For example when a user sends a friend request to another user. The latter must receive an instant notification to approve or deny the request without waiting to refresh the page or re-open the Android application.
MQTT notifications should not be confused with WEB push notifications or android FCM notifications. MQTT notifications are sent using the socket connection established between the android application or the WEB browser and our MQTT server. No intermediary server is used.
An MQTT notification is made up of the following fields:
Name | Description |
userid | id of user that will receive the notification (mandatory) |
title | Notification title (mandatory) |
content | Notification content : text or html (mandatory) |
icon | Url of image or photo to show (optional) |
data | JSON additional data for your application need (optional) |
For example to send Notification using PHP SDK.
PHP
require_once vendor/autoload.php;
$post_data=array("userid":1,
"title":"friend Request",
"content":"John Doe sent you a friend request",
"icon":"https://mqtt-chat.com/photos/12542565.png",
"data":"{\"param1\":1,\"param2\":2}");
$n=new telifoun\mqttchat\notifications();
$result=$n->add($post_data);
{
"ok": true,
"data": {
"notification_id": 8555
}
}
You can get already sent notification content by id.
require_once vendor/autoload.php;
$notification_id=8555;
$n=new telifoun\mqttchat\notifications();
$result=$n->get($notification_id);
Last modified 1yr ago