我想向應用程式中的所有用戶發送通知,Android 開發人員使用 ALL_USER 訂閱了主題名稱,但我無法向該主題發送通知。
感謝您提前提供幫助。
uj5u.com熱心網友回復:
嘗試這個 -
從您的 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); } });
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/510352.html
標籤:Google Cloud Collective javascript节点.js火力基地表示
