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

My ultimate goal is to subscribe web clients to topics in the Firebase cloud service to receive simple push push events separated by keys. This is possible on this issue, but only if you can send client registration keys to the application server that you manage using the FCM admin API: How to subscribe to topics using a browser network using Firebase Cloud Messaging

Also, through https://firebase.google.com/docs/cloud-messaging/js/client , it seems you need to ask the user for permission to display desktop notifications in order to access the registration token for Firebase messaging.

Is there a way to say Firebase not, I absolutely do not want notifications on the desktop, in fact, please never show them, I just want to use data messages and never notification ? And then, to get a registration token? Also, is there another way to subscribe to topics from the web client?

+5
source share
1 answer

There is currently no other alternative for getting a registration token and there is no other way to subscribe to topics for the web client.

You already know this, but you can also mention it. Requesting permissions is mandatory for security purposes (preventing unwanted notifications by the user), and in order to subscribe to the web client in the topic, you first need to get a token (which will not be generated if the user does not grant permission).

+1
source

Source: https://habr.com/ru/post/1267073/


All Articles