Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not receiving Firebase Cloud Messaging delivery receipts

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?

like image 247
Vishnu Avatar asked Jun 12 '18 08:06

Vishnu


People also ask

Does FCM guarantee delivery?

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.

How do I see sent notifications on Firebase?

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.

Is Firebase Cloud Messaging push notifications?

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.

How does FCM push notification work?

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.


1 Answers

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".

like image 156
umang-malhotra Avatar answered Oct 13 '22 00:10

umang-malhotra