【发布时间】:2016-10-21 13:40:45
【问题描述】:
我已经实现了一个 Firebase 云消息传递,它根据它的设备令牌向 Android 设备发送一个通知,它工作正常。
但我想向某个主题发送通知,这很麻烦。
'use strict';
exports.send_push = function(push_array) {
var FCM = require('fcm-node');
var fcm = new FCM("SERVER KEY HERE");
var message = {//this may vary according to the message type (single recipient, multicast, topic, et cetera)
to: 'MY TOPIC TOKEN',
// to: "/topics/foo-bar",
//collapse_key: 'your_collapse_key',
notification: {
title: 'Notification title',
body: 'this is body'
},
data: {//you can send only notification or only data(or include both)
message: "Hello, This is test notification...!"
}
};
fcm.send(message, function(err, response) {
if (err) {
console.log("Something has gone wrong!", err);
} else {
console.log("Successfully sent with response: ", response);
}
});
}
任何人都可以帮助发送有关主题的通知...这里的主题令牌和服务器密钥详细信息是正确的。
【问题讨论】:
-
您收到什么错误?
-
抱歉回复晚了,实际上它只返回
success=0。我认为这个脚本不适用于主题。我们将需要对其进行一些更改。这就是我所问的。
标签: android node.js firebase-cloud-messaging