我可以在没有通知许可的情况下使用 Firebase 云消息传递吗?(Javascript) [英] Can i use firebase cloud messaging without notification permission? (Javascript)

查看:25
本文介绍了我可以在没有通知许可的情况下使用 Firebase 云消息传递吗?(Javascript)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:Google 错误报告说明

(正如谷歌开发倡导者在对答案 1 的评论中所建议的,提交了错误报告;更新这里的内容,因为它更简洁、准确地描述了问题)

(as suggested by google dev advocate in comments on answer 1, filed a bug report; updating the content here since it more succinctly and precisely describes the problem)

我不需要或不想向我的用户显示任何通知.许多用户不愿意授予通知权限,因为他们认为他们会开始看到通知.

I do not need or want to show any notifications to my user. And many users are not willing to give notifications permission because they assume they will start seeing notifications.

但我希望将数据从服务器推送到我的网页.该网页处于活动状态并位于前台.这是 Web Sockets 设计用于的经典用例.

But I wish to push data to my web page from the server. The web page is active and in the foreground. This is the classic use case that Web Sockets were designed for.

我知道我可以编写自己的 Web 套接字服务器并尝试以某种方式对其进行扩展,或者去找其他第三方寻求外包的可扩展 Web 套接字推送解决方案.

I understand that I could write my own web socket server and somehow try to scale it, or go to some other third-party for an outsourced scalable web socket push solution.

但是,这不是 Firebase 消息传递所针对的消息传递的一个非常常见的子用例"吗?因此谷歌不应该支持这个用例吗?我看不到任何基本的技术障碍,但由于 Google 非常聪明,如果我遗漏了为什么不能或不应该这样做的原因,请赐教.

But, isn't this is a very common "sub-use-case" of the messaging that Firebase Messaging is targeted towards? Therefore shouldn't Google support this use case? I can't see any fundamental technical show-stoppers, but since Google is so smart, please do enlighten me if I am missing something on why this cannot or should not be done.

原始 StackOverflow 问题文本:

我不需要后台通知或服务工作者.我想要的只是在当前加载并在前台将数据发送到网页.

I don't need background notifications or service workers. All I want is to send data to the web page when it is currently loaded and in the foreground.

Websockets 不需要任何许可,但它们需要一个 websocket 服务器和维护.扩展它既困难又昂贵.

Websockets do not need any permission but they need a websocket server and maintenance. It is difficult or expensive to scale it.

Firebase 从根本上解决了这个问题,但我不明白为什么它必须要求用户授予通知权限,即使我只想在页面加载时推送数据;不在后台.

Firebase solves the problem fundamentally but I don't see why it must require a user to give notifications permission even though I only want to push data when the page is loaded; not in the background.

推荐答案

问题在于 Firebase Messaging 仅使用 1 种方法来传递通知.这就是 Push API 规范规范,并且该规范(错误且不幸)不允许服务工作者在没有用户允许无关权限显示通知的情况下接收消息.

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.

修复方法是 Firebase 消息传递团队提供一种不同的方式将消息传递到活动网页——长轮询或 websocket.

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.

这篇关于我可以在没有通知许可的情况下使用 Firebase 云消息传递吗?(Javascript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆