4

I am trying to push some data messages to my clients from my cloud functions. These are not really notifications rather they are client specific confidential data that I need to push to the appropriate client.

I do not want to show a notification prompt to my clients, as there is always a chance that some of them might disallow notifications. I need them to always allow by default.

Is there a way to suppress these browser's notification requests? Or is it always mandatory?

In other words, do I always need to call messaging.requestPermission() before calling messaging.getToken()? Or can I call messaging.getToken() independently?

user2970477
  • 119
  • 1
  • 13
  • 1
    You don't need to call `requestPerrmission` before calling `getToken`, as `getToken` already calls `requestPermission` on its own, if needed - https://github.com/firebase/firebase-js-sdk/blob/master/packages/messaging/src/api/getToken.ts#L35 – splintor Jan 30 '22 at 11:08

1 Answers1

2

As far as I know there is currently no way to use the feature to send background messages without requesting permission to display push notifications. So even when you don't display the contents of the messages as a notification, you will have to request permission to do so.

Note that there is movement on this front, such as the quieter permissions UI in Google Chrome, and the quiet notification requests in Firefox.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807