我可以检查Firebase云消息传递日志吗?
有这个help documentation,但它似乎已经过时了。我试了一下,没有运气,我已经没有25美元了。
我正在尝试发送推送通知,而从服务器接受请求时,推送通知就不会发送到浏览器。
从我的服务器提交推送通知时,我收到以下http响应
HTTP/1.1 200 OK [Content-Type: application/json; charset=UTF-8, Date: Fri, 06 Jan 2017 02:06:05 GMT, Expires: Fri, 06 Jan 2017 02:06:05 GMT, Cache-Control: private, max-age=0, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, X-XSS-Protection: 1; mode=block, Server: GSE, Alt-Svc: quic=":443"; ma=2592000; v="35,34", Transfer-Encoding: chunked] [Content-Type: application/json; charset=UTF-8,Content-Length: 119,Chunked: false]
但是当服务器接受输入时,没有任何东西被推送到服务器。 服务工作者已在浏览器中成功注册,当我从开发控制台中选择“推送”选项时,Chrome通知成功显示。
这是我服务工作者的代码。
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');
firebase.initializeApp({
'messagingSenderId': '384333585283'
});
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
console.log('[chrome_sw.js] Received background message ', payload);
// Customize notification here
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: '/firebase-logo.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
self.addEventListener('push', function(event) {
console.log('[Service Worker] Push Received.');
console.log('[Service Worker] Push had this data: '+event.data.text());
const title = 'Push Codelab';
const options = {
body: 'Yay it works.',
icon: 'images/icon.png',
badge: 'images/badge.png'
};
event.waitUntil(self.registration.showNotification(title, options));
});