我想向应用程序中的所有用户发送通知,Android开发人员使用all_USER订阅了主题名称,但我无法向该主题发送通知。
感谢您提前提供帮助。
试试这个-
-
从您的firebase项目下载包含服务器密钥的JSON文件,并将其放在根文件夹privatekey.JSON中。
-
在API或函数中使用以下代码。
var fcm = require('fcm-notification'); var FCM = new fcm('./privatekey.json'); var message = { topic: topic, notification: { title: title, body: body } }; FCM.send(message, function (err, response) { if (err) { console.log("Something has gone wrong!" + err); } else { console.log("Successfully sent with response: ", response); } });