Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a registration token for Firebase Cloud Messaging without requesting permission for notifications?

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?

like image 639
jonvuri Avatar asked Apr 23 '17 23:04

jonvuri


1 Answers

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

like image 175
AL. Avatar answered Oct 21 '22 16:10

AL.