Can i use firebase cloud messaging without notification permission? (Javascript)

后端 未结 2 1512
庸人自扰
庸人自扰 2020-12-02 02:03

Update: Google Bug Report Description

(as suggested by google dev advocate in comments on answer 1, filed a bug report; updating the content here si

相关标签:
2条回答
  • 2020-12-02 02:31

    It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.

    Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.

    0 讨论(0)
  • 2020-12-02 02:33

    The problem is that Firebase Messaging is only using 1 method to deliver notifications. That is the Push API specification spec, and that specification (wrongly and unfortunately) does not allow a service worker to receive messages without the user allowing an unrelated permission to show notifications.

    The fix would be for the Firebase Messaging team to provide a different way to deliver messages to active web pages -- long polling, or websockets.

    But it would be extra work for them, and may be not enough people are requesting it.

    0 讨论(0)
提交回复
热议问题