admin管理员组文章数量:1415476
My end goal here is to subscribe web clients to topics in Firebase Cloud Messaging to receive simple data push events, partitioned by keys. Via this question, that seems to be possible, but only if you can send the clients' registration keys to an app server you control using the FCM Admin API: How to subscribe to topics with web browser using Firebase Cloud Messaging
Also, via , it seems to be required to request permission from the user to show desktop notifications in order to get access to the registration token for Firebase messaging.
Is there any way to tell Firebase no, I absolutely do not want desktop notifications, in fact please never show them, I just want to use data
messages and never notification
? And then, to get the registration token? Alternatively, is there some other way to subscribe to topics from a web client?
My end goal here is to subscribe web clients to topics in Firebase Cloud Messaging to receive simple data push events, partitioned by keys. Via this question, that seems to be possible, but only if you can send the clients' registration keys to an app server you control using the FCM Admin API: How to subscribe to topics with web browser using Firebase Cloud Messaging
Also, via https://firebase.google./docs/cloud-messaging/js/client, it seems to be required to request permission from the user to show desktop notifications in order to get access to the registration token for Firebase messaging.
Is there any way to tell Firebase no, I absolutely do not want desktop notifications, in fact please never show them, I just want to use data
messages and never notification
? And then, to get the registration token? Alternatively, is there some other way to subscribe to topics from a web client?
- I agree with this question. It's not a security issue if I don't want to trigger official browser notifications, but only want a javascript event to fire. The firebase database can function without special user permissions. – efreed Commented Jul 31, 2018 at 18:49
- Hey, have you found out if this is possible? I'm looking at firebase as an alternative to web sockets (in order to send simple push messages to a user viewing a website, since I don't care about desktop notifications at all) – Cristiano Coelho Commented Dec 14, 2018 at 23:33
2 Answers
Reset to default 2There is currently no other alternative to get a registration token nor is there a different way to subscribe to topics for a web client.
You already know this, but might as well mention it. Requesting permissions is a must for security purposes (preventing notifications not wanted by the user) and that in order to subscribe a web client to a topic, you'll first have to get a token (which won't generate unless the user grants permission).
Looks like you are looking for Pusher
User channel for munication. Works with out token and support bidirectional contact.
Sample code
Back End
pusher->trigger('my-channel', 'my-event', [
'message' => 'hello world'
]);
Front End
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
alert('Received my-event with message: ' + data.message);
});
本文标签:
版权声明:本文标题:javascript - How to get a registration token for Firebase Cloud Messaging without requesting permission for notifications? - Sta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745169940a2645912.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论