Log In

Starting from Android 13, there is a requirement to request for Notification Permission in new apps. This section will detail the manifest edit needed, and different scenarios as detailed in the official Google Developer documentation. Note that there are two scenarios: newly installed app, and existing app that was on the device when it upgraded to Android 13.


Android 12 pre-grant when updating to Android 13

For your app to be eligible for an automatic pre-grant, it must have an existing notification channel and not have its notifications explicitly disabled by the user on a device that runs 12L or lower.

If the user disabled notifications for your app on a device that runs 12L or lower, that denial persists when the device upgrades to Android 13 or higher.

Requesting permissions at runtime

MOCA SDK requires the android.permission.POST_NOTIFICATIONS permission for Push Notifications and Local Notifications.

This is an example of how to request these permissions.

<manifest ...>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <application ...>

This will allow the app to request for this permission on runtime. The user will select if they'd like to allow, don't allow or they can swipe away.

If they allow your app can Send notifications. All notification channels are allowed. Post notifications related to foreground services. These notifications appear in the notification drawer.

If the user selects the don't allow option, your app can't send notifications.

If the user swipes away from the dialog—that is, they don't select either allow or don't allow—the state of the notification permission doesn't change.

Below you will find an example of how to implement this method, and how to initialize the permission-affected MOCA Services:

Learn more about requesting Notification Permissions at Run Time. (external link).