I am sending the following message through fcm xmpp client. But I am not getting delivery receipt for the delivered messages.
I am using node-xcs
node package for sending XMPP message.
var Sender = require('node-xcs').Sender;
var Message = require('node-xcs').Message;
var Notification = require('node-xcs').Notification;
var Result = require('node-xcs').Result;
var xcs = new Sender('123', 'xxxx', 1);
const uuidv4 = require('uuid/v4');
xcs.on('message', function(messageId, from, data, category) {
console.log('received message', arguments);
});
xcs.on('receipt', function(messageId, from, data, category){
console.log(messageId,'dsafdsafdsaf')
});
xcs.on('connected', function(){console.log('connected')});
xcs.on('disconnected', function(){console.log('disconnected')});
xcs.on('online', function(){console.log('online')});
xcs.on('error', console.error);
xcs.on('message-error', function(){console.log('message-error')});
var notification = new Notification("./logo.png")
.title("Hello buddy!")
.clickAction("https://github.com/guness/node-xcs/blob/master/google/Notification.js")
.body("test_body")
.build();
var message = new Message(uuidv4())
.priority("high")
.dryRun(false)
.deliveryReceiptRequested(true)
.notification(notification)
.build();
xcs.sendNoRetry(message, 'token', function(result) {
if (result.getError()) {
console.error(result.getErrorDescription());
} else {
console.log("message sent: #" + result.getMessageId());
}
});
Below is the XMPP message sent from the package
<gcm xmlns="google:mobile:data">{
"to": "token",
"message_id": "59171fc6-42ad-4f22-812f-d0c4f7fa63d0",
"priority": "high",
"delivery_receipt_requested": true,
"notification": {
"body": "test_body",
"click_action": "https://github.com/guness/node-xcs/blob/master/google/Notification.js",
"icon": "./logo.png",
"title": "Hello buddy!"
}
}</gcm>
I am getting ack
, but I am not getting Delivery receipt, Why is the delivery receipt not coming even if the message is delivered?
FCM does not guarantee the order of delivery. Some typical use cases of non-collapsible messages are chat messages or critical messages. For example, in an IM app, you would want to deliver every message, because every message has different content.
You can log into your firebase console and check the Cloud Messaging section for the detailed overview of the notifications sent. You can check this answer as well for better understanding. To understand more about the lifetime of a message, you can see their developer documentation here.
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
The FCM backend receives the message request, generates a message ID and other metadata, and sends it to the platform specific transport layer. When the device is online, the message is sent via the platform-specific transport layer to the device. On the device, the client app receives the message or notification.
node-xcs is based on the works of node-gcm-ccs and it's not properly maintained.
See disclaimer in the last of node-xcs
You can not even send notifications to ios Devices as it was only build to support sending FCM to android and web devices.
See here, it says that it's not maintained in very bold letters.
I recommend using fcm-push instead of using node-xcs
Last year I had faced similar issues with this library and I switched to fcm-push after reading these very bold messages of "NOT MAINTAINED NOT MAINTAINED NOT MAINTAINED".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With