未收到 Firebase 云消息传递的送达回执。

16

我正在通过FCM XMPP客户端发送以下消息。 但是,我没有收到已发送消息的送达回执。

我正在使用node-xcs节点包发送XMPP消息。

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());
    }
});

以下是从该包发送的XMPP消息

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

我会收到ack,但没有收到交货收据,为什么即使消息已经传递,交货收据也没有到达?


我正在做一些我通常警告别人不要做的事情——尝试在完全不熟悉领域基础知识的情况下解决问题 :) 你希望收到交付收据的位置在哪里?在GCF标准输出的控制台上吗? - user2347763
console.log(messageId,'dsafdsafdsaf'),我想要消息的送达回执,以便标记消息已被送达。 - Vishnu
node-xcs 只能与 node.js 版本 <= 11 兼容,不幸的是它无法与 12 和 13 版本兼容。 - Pavel Biryukov
1个回答

1

node-xcs基于node-gcm-ccs的作品,但它没有得到很好的维护。
请参阅node-xcs末尾的免责声明。
你甚至无法向iOS设备发送通知,因为它只支持向Android和Web设备发送FCM。

请参见此处,它用非常粗体的字说它没有得到很好的维护。
我建议使用fcm-push而不是使用node-xcs

去年我遇到了类似的问题,我在阅读了这些非常粗体的“NOT MAINTAINED NOT MAINTAINED NOT MAINTAINED”信息后切换到了fcm-push。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接