Home > front end >  Prevent Android 13 from showing the notification permission prompt
Prevent Android 13 from showing the notification permission prompt

Time:01-19

Android 13 automatically asks the user if they would like to allow the app to send them notifications.

My app does not show any notifications, therefore it doesn't make any sense to ask the user for push notifications at this time. I would like to defer this prompt for when we actually have notifications and a well defined permissions UX.

How do you tell Android 13 to not ask for the permission automatically?

CodePudding user response:

My app does not show any notifications

Something — perhaps a library — is doing something related to notifications, such as setting up a notifications channel. That will trigger the notification permission prompt.

IOW, the existence of that prompt means that something is working with notifications. You can tell this by creating a scrap "Hello, world!" project in your IDE, running it on your Android 13 device, and noticing that the notification permission prompt does not appear.

How do you tell Android 13 to not ask for the permission automatically?

Remove the code that is working with notifications. For example, you might check your app's page in Settings and see if any notification channels are set up, and see if their names help you identify what code is creating those channels.

CodePudding user response:

Try to upgrade targetSdk and compileSdk to 33

If your notification feature is optional for users, you could migrate apps to Android 13 to control the timing of requesting Notification runtime permission by yourself. (System won't auto ask for notification permission on android 13 devices)

  • Related