Android Notification Runtime Permissions

Android 13 (API level 33) and higher supports runtime permission for sending non-exempt(including Foreground Services (FGS)) notifications from an app POST_NOTIFICATIONS. This change helps users focus on the notifications that are most important to them.

Refer to the official documentation for more details.

The below-mentioned APIs are supported starting MoEngage core Android SDK version 12.3.01

When an application runs on Android 13 and wants to show notifications to the user, it must request the user's notification permission. You have two options: let MoEngage handle permissions for you or handle the notification permission with your code.

  • MoEngage handles Notification permission.
    • You just have to call a single line of code mentioned on this page.
  • You maintain the notification permission logic.
    • Notify MoEngage SDK if permission to push notifications is granted.

We recommend you let MoEngage handle push notification permissions.

Let MoEngage SDK handle Notification permission

MoEngage SDK provides helper APIs to show the permission request to the end-user or navigate the user to the settings screen for enabling notifications.

Use the below API to show the permission request dialog to the user.

When using the below API SDK automatically tracks the response, sets up the required notification channel, etc, mentioned above.

import ReactMoE from 'react-native-moengage'

Notify SDK of permission result

Once the application requests the user for notification permission notify the SDK of the user response using the below API. If you are letting MoEngage SDK handle the notification permissions, you should ignore this step.

import ReactMoE from 'react-native-moengage'

Update the Permission request count(optional)

Once the application requests the user for notification permission, update the SDK of the request attempts. 

Why does the SDK require permission attempt count?

SDK requires the attempt count to accurately track the number of times the permission request was attempted. If the user denies the permission request twice the application/SDK cannot request permission further i.e. if we request permission it would be automatically denied without the user seeing the request dialog. As an SDK we cannot be sure of the number of times the user has denied the permission we try to optimize the calls to request permission based on the attempt count.

import ReactMoE from 'react-native-moengage'

Navigate to Notification Settings (situational/optional)

Use the below API to show navigate the user to the Notification Settings for the application on the device.

Note: Below Android 8(API level 26) the user is directed to the Application Info screen of your application.

import ReactMoE from 'react-native-moengage'



Was this article helpful?
0 out of 1 found this helpful

How can we improve this article?