I only need fcm for sharing data and not for notification. Is it mandatory to ask for notification permission for that?
-
What do you mean by "sharing data"? – Rosário Pereira Fernandes Feb 11 '18 at 14:31
-
@RosárioPereiraFernandes I mean sending some text from one client to another – Gaurav Verma Apr 24 '18 at 12:10
1 Answers
I realize no one is likely to see this answer, but I came across this while researching... thought I'd include the answer for future viewers.
Yes, it is mandatory to ask for permission, even if you don't intend to show the user a notification. There's been a recent question here asking the same basic question: Can i use firebase cloud messaging without notification permission? (Javascript) that has a couple good answers explaining why by people way smarter and more experienced than me.
In case anyone can't access that question in the future, I'll include Google Dev Adocate Doug Stevenson's excellent concise explanation here:
It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.
Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.

- 5,157
- 6
- 29
- 30