Android 13: Notification Runtime Permission

Umang Chamaria
4 min readMay 3, 2022

--

Up until Android 13, applications did not require explicit user permission to post notifications. Applications could post notifications soon after application launch, and end-users always had the option to disable notifications from settings but by default, notifications were enabled.

In Android 13, to help users focus on the notifications that are most important a new runtime permission is introduced for posting notifications. The user needs to grant this runtime permission for the application to show non-exempt notifications.

Permission for Notification

The application needs to request POST_NOTIFICATIONS permission for posting the notification. The permission request flow would be similar to any other runtime permission(s) the application might request for.

This permission is marked as dangerous permission.

Before requesting the notification permission, let the user familiarise themself with the application, and provide context to the user on why should they grant permission. Refer to the best practices on how you can effectively request permission.

What does the permission look like?

Notification Permission Dialog

Above is a screenshot of what the notification permission dialog looks like. The user can either choose to allow or deny notification permission.

Application Capabilities based on Permission

When a permission dialog is shown to the user the has the following options

  • Select Allow
  • Select Don’t Allow
  • Swipe away from the dialog, without selecting either option.

Select Allow: If the user selects the allow option, the applications can do the following

  • Send notifications, all notifications channels are allowed.
  • Post notifications related to foreground services.

Select Don’t Allow: If the user selects the don’t allow option, the application cannot send notifications. All notification channels are blocked, except for a few specific roles. This is similar to the behavior that occurs when the user manually turns off all notifications for the application in system settings.

Swipe away from the dialog: If the user swipes away from the dialog, i.e. they don’t select either allow or don’t allow the following behavior occurs

How does the Android 13 update affect the existing applications?

To minimize the disruption due to the new permission some devices pre-grant the new notification permission, on other devices system automatically grants notification permission temporarily to all eligible applications installed on the device prior to the Android 13 upgrade. The length of the temporary grant depends on the target SDK version of the application, described as follows:

  • If the application targets Android 13 or above the temporary grant lasts till the user launches the application for the first time.
    The application has complete control over when the permission dialog should be shown post the application launch.
  • If the application targets Android 12L or below the grant lasts until the user explicitly selects an option in the runtime permission dialog. If the user dismisses the permission dialog without a selection the system will persist with the temporary grant.

What happens to the new applications installed on Android 13?

By default, notifications are off for all applications installed on Android 13. Applications should wait for the user to grant notification permission before showing a notification.

When does the notification permission dialog show up?

The time at which the permission dialog is shown depends on the application’s target SDK version:

  • If the application targets Android 13(API level 33) or above it has full control over when to request the notification permission. The application can choose to explain to the users why permission is needed before asking for permission.
  • If the application targets Android 12L(API level 32) or below the system shows the permission dialog the first time an activity is launched after a notification channel is created, or immediately when an application starts an activity and then creates a notification channel.

How many times can the application ask the user for permission?

  • If the application targets Android 13(API level 33) or above application can request notification permission any number of times till the user explicitly denies the permission twice i.e. clicks on the Don't Allow button twice.
  • If the application targets Android 12L(API level 32) or below the application can request notification permission any number of times until the user denies the permission once i.e. click’s on the Don't Allow button once.

Note: If the user clicks somewhere outside the dialog the application can continue showing the permission any number of times until the above conditions are met.

After the application receives approval to send notifications, it should use the permission responsibly. Users can see the number of daily notifications that your app sends, and they can revoke the permission at any time.

--

--