Firebase客户端不接收邮件
我有以下的Node.js script
:
var registrationToken = "Long Token"; var serviceAccount = require("./config/ServiceAccount.json"); var payload = { data: { score: "850", time: "2:45" } }; admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: fireBaseConfig.databaseURL }); admin.messaging().sendToDevice(registrationToken, payload) .then(function(response) { // See the MessagingDevicesResponse reference documentation for // the contents of response. console.log("Successfully sent message:", response); }) .catch(function(error) { console.log("Error sending message:", error); });
运行时,我得到了一个success
回应:
Successfully sent message: { results: [ { messageId: '0:1502813815410638%e609af1cf9fd7ecd' } ], canonicalRegistrationTokenCount: 0, failureCount: 0, successCount: 1, multicastId: 5249778920849394000 }
然后我有我的客户:
firebase.initializeApp(config); var messaging = firebase.messaging(); messaging.requestPermission() .then(function () { messaging.onMessage(function(payload) { console.log("Message received. ", payload); // ... }); console.log('I am in here'); return messaging.getToken() .then(function (currentToken) { console.log(currentToken); }) .catch(function (err) { console.log('An error occurred while retrieving token. ', err); showToken('Error retrieving Instance ID token. ', err); setTokenSentToServer(false); }); }).catch(function (err) { console.log('Error'); }); messaging.onMessage(function(payload) { console.log("Message received. ", payload); // ... });
现在我首先(作为我的客户端)进入网站,然后我在控制台中得到令牌,然后在后端(Node.js)中使用该令牌并发送消息(而客户端的点击仍处于打开状态)然而没有任何反应
谁能告诉我我做错了什么?
- 如何从节点服务器发送Firebase云消息传递?
- 尝试通过Firebase云端function发送通知(Android)后出现错误
- 错误:加载firebase.json时出现错误:未安装Bolt,运行npm install -g firebase-bolt
- firebase表示云function错误
- 从Firebasefunction访问Google Site Verification API
- 迁移到新控制台后,Firebase部署被破坏 – “错误:需要身份validation”。
- Firebase函数signInWithCustomToken与Node.js一起未定义
- Firebase 3.3.x Nodejs – createUserWithEmailAndPassword不是一个函数
- 如何在NodeJS中创build一个新的Firebase Admin SDK服务器以与LinkedIn进行身份validation?