9
votes

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.com/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?

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
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

2 Answers

3
votes

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).

0
votes

Looks like you are looking for Pusher

User channel for communication. 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);

});