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?

Share Improve this question edited May 23, 2017 at 11:54 CommunityBot 11 silver badge asked Apr 23, 2017 at 23:27 jonvurijonvuri 5,9503 gold badges27 silver badges33 bronze badges 2
  • 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
Add a ment  | 

2 Answers 2

Reset to default 2

There 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);

});

本文标签: