Grinton
Grinton

Reputation: 3

Android - permission to receive Firebase push notifications

Can I ask users' permission to receive Firebase push notifications and to allow users to opt out from receiving push notifications when first run the app?

I know that push notification permissions are included in the normal and not dangerous category permissions and we don't have to ask for push notification permission but is there any workaround?

Upvotes: 0

Views: 1969

Answers (1)

gtxtreme
gtxtreme

Reputation: 3566

Basically what you would want to do in this case is use the Firebase Subscriptions.

Firebase Subscriptions allows you to subscribe or unsubscribe to a particular topic and that allows for a behaviour like only the users which are subscribed to a particular topic will receive the push notifications

You can subscribe or unsubscribe a user from the topic or in simple words stop or enable notifications based on a toggle in the settings say for example

To see a sample as to how to subscribe to a topic you can do something like

FirebaseMessaging.getInstanceId().subscribeToTopic("topic")

More details here

And then to unsubscribe you can check this example

For more info about subscriptions you can refer to official Firebase Docs

Upvotes: 1

Related Questions