Not receiving Firebase Cloud Messaging delivery receipts
Asked Answered
C

1

16

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?

Caribou answered 12/6, 2018 at 8:7 Comment(3)
I am doing something here that I usually warn others from doing - trying to resolve a problem without even being familiar with the basics of the domain :) where are you expecting the delivery receipt? On the console of the GCF stdout?Gestation
console.log(messageId,'dsafdsafdsaf'), I want the delivery receipt of the message, which can i use for marking message is delivered.Caribou
node-xcs works with node.js version <= 11. It does not work with 12 and 13 unfortunately...Fermanagh
E
1

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

Execrative answered 27/6, 2019 at 23:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.