我正在使用 node-xcs 模块在 NodeJs 中创建 XMPP CCS 服务器,但是在该模块中没有发送 ACK 消息的方法,需要发送回 FCM。
最佳答案
您是否使用 fcm-node 包来获取 FCM token 。使用它我们可以注册设备看看我的完整编码我用它向手机发送通知
var FCM = require('fcm-node');
exports.SendNotification = function(msg,title,type,id,user_id,api_token)
{
var fcm = new FCM(constants.serverKey);
var message = {
registration_ids : api_token,
notification: {
title: title,
body:msg
},
data: {
type: type,
id:id,
user_id:user_id
}
};
fcm.send(message, function(err, response){
if (err)
{
console.log("Error for Send Notification",err);
return;
}
else
{
console.log("Successfully sent Notification", response);
return;
}
});
}
然后像这样调用这个函数
msg='new notification for you'
title='Hello'
id='34'
user_id='34'
result='api_token'//save this token in database and retrive using user_id
SendNotification(msg,title,'START_APPOINTMENT',id,user_id,result);
关于android - 如何在 Node 服务器中处理 FCM 上游消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39189237/