Фоновые уведомления не отображаются - PullRequest
0 голосов
/ 31 марта 2019

enter image description here Я новичок в облачной системе обмена сообщениями Firebase и пытаюсь настроить систему уведомлений на nodeJS.Я следовал за документами на сервис-работнике и всем остальном, однако есть проблема, что браузер не отображает уведомления, даже если они достигают клиента.

service worker code :
importScripts("https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js");
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
  messagingSenderId: "901639143723"
});
// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
  console.log(
    "[firebase-messaging-sw.js NOIS] Received background message ",
    payload
  );
  var notificationTitle = "Background Message Title";
  var notificationOptions = {
    body: "HI"
    icon: "/firebase-logo.png"
  };
  console.log(
    self.registration.showNotification(notificationTitle, notificationOptions)
  );
  return self.registration.showNotification(
    notificationTitle,
    notificationOptions
  );
});
[![enter image description here][1]][1]
// Customize notification here
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...