How to Enable Notification Runtime Permission in Android 13?
Last Updated :
24 Apr, 2025
Android 13 starts a new realm of new app permissions which are focussed on users' privacy and peace of mind, one of which is the permission to send notifications to the user. Notifications are an integral part of the Android Operating System, but when you have tons of apps installed, then receiving notifications from them starts getting worse. Starting from this Android Version, one can op-tin to which notification they want and which they don't, something which Apple has now been doing for quite a time.
In order to take use of the extra control and flexibility offered by this feature, we strongly advise that you target Android 13 or higher as soon as feasible. Continued targeting of 12L (API level 32) or lower limits your ability to ask for authorization in the context of the functionality of your app.
Declare the Authorization
Update your program to target Android 13 and use the same steps as when seeking other runtime rights, as explained in the following sections, to ask for the new notification permission. As with all the other permissions which we request throughout developing for Android Ecosystem, we will, first of all, update the Manifest File to tell the system that we are now using the newer permissions and then move forward. The first step would be to add the permission line to our App's Manifest! To add the permission, do this:
<manifest ...>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
</manifest>
Note: To launch a foreground service, apps do not need to ask for the POST NOTIFICATIONS permission. Similar to earlier versions of Android, apps must include a notification when they launch a foreground service.
User decisions in the permissions dialogue determine the app's capabilities:
When permission is required from the user while the app is running the user is presented with the following actions which the user can take:
- Choose "allow".
- Choose "don't allow".
- Push neither of the buttons as you swipe away from the dialogue.
According to the user's behavior, the following sections describe how your program acts.
The user chooses "Allow"
The following is possible for your app if the user chooses the allow option:
- Send out alerts.
- All notification methods are acceptable.
- Notify users of foreground services via postings.
- The notification drawer displays these notifications.
The user chooses "Don't allow"
The worst case scenario for your app would be when there is a denial to your request, then the following channel activates
- Your app cannot send alerts if the user chooses the don't allow option unless it is exempt from this requirement.
- With the exception of a few specified positions, all notification channels are banned.
- This behavior is comparable to what happens when a user manually disables every notification for your app in the system settings.
What if the user simply swipes to go back to the home without choosing anything?
When such a situation arises, then the Android System does not assign any state to your application, and the prompts will re-appear when the user opens the app the next time!
Note: If your application targets 12L or lower and a user taps Don't allow even once, they aren't prompted again until your app is updated to support Android 13 or above.
Eligibility for pre-grant permission
Your app must already have a notification channel and not have its notifications expressly turned off by the user on a device running 12L or lower in order to qualify for an automatic pre-grant. When a device updates to Android 13 or higher, the denial still stands if the user deactivated alerts for your app on a device running Android 12L or lower.
Asking for permissions on Runtime:
When the user has started using your app you can use the below code to ask for permission to show the notifications, it's upon them now to either accept or not based on their decision.
Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.gfg_main_activity)
val gfgMessage = intent?.getStringExtra(NOTIFICATION_GFGMESSAGE_TAG)
findViewById<TextView>(R.id.tv_gfgMessage).text = gfgMessage
findViewById<Button>(R.id.click).setOnClickListener {
when {
ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) ==
PackageManager.PERMISSION_GRANTED -> {
Log.e(TAG, "User accepted the notifications!")
sendNotification(this)
}
shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> {
Snackbar.make(
findViewById(R.id.parent_layout),
"The user denied the notifications ):",
Snackbar.LENGTH_LONG
)
.setAction("Settings") {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val uri: Uri =
Uri.fromParts("com.onesilisondiode.geeksforgeeks", packageName, null)
intent.data = uri
startActivity(intent)
}
.show()
}
else -> {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}
}
}
By adding this code, you will be able to present the user with the pop-up to ask for permission to show notifications, if the user enables the notifications you will be able to deliver your notifications as you want, otherwise sadly all your App notifications will be blocked.
Conclusion
The app may be explored by new users so they may experience first-hand the advantages of each specific notification request. User activity can start a permissions prompt. Once you have been given the authorization to send notifications, use it wisely. The number of daily notifications sent by your app is visible to users, and they have the option to remove permission at any moment.
Similar Reads
How to Disable Notification in Android Studio?
Android Studio is the official IDE (Integrated Development Environment) for Android app development and it is based on JetBrainsâ IntelliJ IDEA software. Android Studio provides many excellent features that enhance productivity when building Android apps, such as: A blended environment where one can
1 min read
How to Dismiss Running App Notifications in Android 13?
You may be accustomed to seeing the default notifications which every running app shows you while it is running on your device, like your watch companion app, or any other app, which shows you notifications, but that is history now, as from Android 13, those notifications can be just simply swiped l
4 min read
How to Push Notification in Android?
A notification is a message that appears outside of our Application's normal UI. A notification can appear in different formats and locations such as an icon in the status bar, a more detailed entry in the notification drawer, etc. Through the notification, we can notify users about any important up
14 min read
How to Increase Push Notification Delivery Rate in Android?
Notifications are an essential component of any application. Almost every application on your mobile device will send some kind of notification. The WhatsApp notification is one of the best examples of this. Whenever you receive a message, it is displayed on your phone in the form of notifications.
8 min read
How to Schedule Notifications in Android?
In this article, we will see the process of scheduling notifications in Android for specific dates and times and also it can run both in the foreground and background. This is particularly valuable when developing apps that allow users to be notified of events at predefined moments enhancing the ove
5 min read
Notifications in Android with Example
Notification is a kind of message, alert, or status of an application (probably running in the background) that is visible or available in the Android's UI elements. This application could be running in the background but not in use by the user. The purpose of a notification is to notify the user ab
7 min read
How to Request Permissions in Android Application?
Starting from Android 6.0 (API 23), users are not asked for permissions at the time of installation rather developers need to request the permissions at the run time. Only the permissions that are defined in the manifest file can be requested at run time.Types of Permissions1. Install-Time Permissio
5 min read
Android progress notifications in Kotlin
In this tutorial you'll learn how to create a basic Progress Notification (Indeterminate progress indicator and Fixed-duration progress indicator) for Android using Kotlin. Before we begin, let us first understand the components of a Notification in Android. Components of a Notification:Small Icon -
4 min read
Multiple Runtime Permissions in Android with Kotlin using Dexter
From MarshMallow android introduced runtime permissions, we can grant the permissions while using the app, instead of while installing the app. Â In general, If you want to use a camera or make a call from your app you will ask for the user's permission. There are some predefined functions provided t
3 min read
Notifications in Android Oreo (8+)
Android Oreo has brought in a ton of changes. This also includes the way in which a user issue notifications in an app. In this article, we will discuss the changes required to be made in the notification department. The following things are to be kept in mind while issuing notifications:Designing a
4 min read