---
agentTools:
  projectIndex: https://docs.nvecta.com/llms.txt
---

# Notification Runtime Permission (Android)

Android 13 (API level 33) and higher supports runtime permission for sending non-exempt (including Foreground Services (FGS)) notifications from an app.

We recommend targeting Android 13 or higher as soon as possible to benefit from this feature's additional control and flexibility. Click [here](https://developer.android.com/develop/ui/views/notifications/notification-permission) to learn more about push prompt notification permission.

## How to configure the prompt in your app

The SDK offers you three different ways to manage the prompt configuration.

## Import Package

```javascript React-Native
import { PushPromptInfo } from 'react-native-notifyvisitors';
```

## Option 1: Your own designed popup with your logic

Whenever the user consents to receive push notifications via a system-generated permission prompt, then **call** the undermtioned function by means of following the step by step procedure delineated below. This particular function will inform the NotifyVisitors SDK that the user has granted the permission to receive the notifications.

```Text JavaScript
Notifyvisitors.checkPushActive(true);
```

> **isAllowed:** A boolean type parameter that tells NotifyVisitors Android SDK whether the user accepted or denied the permission. Pass TRUE when the user allows it and pass FALSE when it is denied.

## Option 2: SDK’s designed pop-up with logic

An illustration of the default UI of the **SDK’s Push Permission Prompt** has been provided below. Customizations are available as shown in the screenshots. We have **two template designs** for permission prompts. Each contains **four parts** viz. title, description, a positive option as button 1, and a negative option as button 2.

[block:html]
{
  "html": "<div style=\"margin-bottom: 22pt !important;\"></div>"
}
[/block]

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/e0b1180-Android_Update_1.png",
        "",
        ""
      ],
      "align": "center",
      "sizing": "64% "
    }
  ]
}
[/block]

\[ **Template 1** ]

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/86973b3-Android_Update_2.png",
        "",
        ""
      ],
      "align": "center",
      "sizing": "64% "
    }
  ]
}
[/block]

\[ **Template 0** ]

[block:html]
{
  "html": "<div style=\"margin-bottom: 20pt !important;\"></div>"
}
[/block]

To achieve this follow the undermentioned steps:

#### Add the undermentioned code to your class

```javascript JavaScript
let design = new PushPromptInfo();
design.title = "Test Title";
design.titleTextColor = "#000000";
design.description = "Enable Push Notifications on Your Device !!";
design.descriptionTextColor = "#000000";
design.backgroundColor = "#EBEDEF";
design.buttonOneBorderColor = "#6db76c";
design.buttonOneBackgroundColor = "#26a524";
design.buttonOneBorderRadius = "0";
design.buttonOneText = "Allow";
design.buttonOneTextColor = "#FFFFFF";
design.buttonTwoText = "Cancel";
design.buttonTwoTextColor = "#FFFFFF";
design.buttonTwoBackgroundColor = "#FF0000";
design.buttonTwoBorderColor = "#6db76c";
design.buttonTwoBorderRadius = "0";
design.numberOfSessions = "3";
design.resumeInDays = "1";
design.numberOfTimesPerSession = "6";

Notifyvisitors.pushPermissionPrompt(design, function (response: any) {
      //do your work here
});
```
```typescript
const design = new PushPromptInfo();
        design.title                  = 'Test Title';
        design.titleTextColor         = '#000000';
        design.description            = 'Enable Push Notifications on Your Device !!';
        design.descriptionTextColor   = '#000000';
        design.backgroundColor        = '#EBEDEF';
        design.buttonOneBorderColor   = '#6db76c';
        design.buttonOneBackgroundColor = '#26a524';
        design.buttonOneBorderRadius  = '0';
        design.buttonOneText          = 'Allow';
        design.buttonOneTextColor     = '#FFFFFF';
        design.buttonTwoText          = 'Cancel';
        design.buttonTwoTextColor     = '#FFFFFF';
        design.buttonTwoBackgroundColor = '#FF0000';
        design.buttonTwoBorderColor   = '#6db76c';
        design.buttonTwoBorderRadius  = '0';
        design.numberOfSessions       = '3';
        design.resumeInDays           = '1';
        design.numberOfTimesPerSession = '6';
        Notifyvisitors.pushPermissionPrompt(design, (response: any) => {
          //do your work here
        });
```

Notice that there are two parameters in the function above namely **numberOfSessions** and **resumeInDays**. These two parameters will handle the flow of SDK’s push prompt permission (not system’s permission dialog).

**numberOfSessions** → This parameter takes integer as input. In NV SDK, new or next session is created either on first app launch or after 30 minutes of user’s inactivity. So, if you set 3, then prompt will be displayed for next 3 sessions including current session in case user denies the prompt in every attempt.

**resumeInDays** → This parameter takes integer as input. When numberOfSessions set by you is completed then resumeInDays parameter will work. This is used to control the time period in days after which you intend to show the prompt again to the user. So, if you set 10 then prompt will remain hidden for 10 days and from the 11th day onwards it will get displayed according to the condition set in numberOfSessions parameter.

## Option 3: Activate Native Permission Prompt

If you want to opt for a native permission prompt or system-designed prompt from NotifyVisitors SDK,  you can add the below code to your activity.

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/591f0eb3b8e0e802c8ff10a1cb72203a4ebae04b0c4e08dd8f62eaf0b9376e9c-image.png",
        null,
        ""
      ],
      "align": "center",
      "sizing": "300px"
    }
  ]
}
[/block]

Keep in mind that you can request permission from the user a maximum of two times. If the user declines both times, you won't have the opportunity to ask again. The only option available to you is to guide the user to the notification permission settings page of your app.

```javascript JavaScript
Notifyvisitors.nativePushPermissionPrompt(function(callback: JSON){
        //do your work here
});
```
```typescript
Notifyvisitors.nativePushPermissionPrompt((callback: JSON) => {
          //do your work here
});
```

#### Output with callback

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/37e3739-5.png",
        "",
        ""
      ],
      "align": "center"
    }
  ]
}
[/block]

[block:html]
{
  "html": "<div style=\"margin-top: 16pt !important;\"></div>"
}
[/block]

```text
{
   "status":"success",
   "message":"Popup launched. User granted permission."
}
```

[block:html]
{
  "html": "<div style=\"margin-bottom: -28pt !important;\"></div>"
}
[/block]

<br />

## Callback responses

Here are some of the '**callbacks**' you can receive in the function mentioned above in Option 2 and Option 3.

[block:html]
{
  "html": "<table class=\"fr-dashed-borders\" style=\"width: 100%; margin-right: calc(0%); margin-top: 21.5pt !important; margin-bottom: 5pt !important;\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td dir=\"ltr\" style=\"width: 25.0877%;\">\n\t\t\t\t<div dir=\"ltr\" style=\"text-align: center; font-weight: 600 !important;\"><span style=\"font-size: 12.375pt !important;\">STATUS</span></div>\n\t\t\t</td>\n\t\t\t<td dir=\"ltr\" style=\"width: 74.9123%;\">\n\t\t\t\t<div style=\"text-align: center; font-weight: 600 !important;\"><span style=\"font-size: 12.375pt !important;\">MESSAGE</span></div>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td rowspan=\"4\" style=\"width: 25.0696%; text-align: center; vertical-align: middle;\">\n\n\t\t\t\t<p dir=\"ltr\" style=\"text-align: center; font-size: 11.5pt !important; font-weight: 500 !important; font-family: Roboto, sans-serif !important;\">Success</p>\n\t\t\t\t<br>\n\n\t\t\t\t<p dir=\"ltr\" style=\"text-align: center;\">\n\t\t\t\t\t<br>\n\t\t\t\t</p>\n\t\t\t\t<br>\n\n\t\t\t\t<p dir=\"ltr\" style=\"text-align: center;\">\n\t\t\t\t\t<br>\n\t\t\t\t</p>\n\t\t\t\t<br>\n\n\t\t\t\t<p dir=\"ltr\" style=\"text-align: center;\">\n\t\t\t\t\t<br>\n\t\t\t\t</p>\n\t\t\t</td>\n\t\t\t<td dir=\"ltr\" style=\"width: 74.9123%; text-align: center;\">\n\t\t\t\t<div style=\"text-align: center;\"><strong dir=\"ltr\"><span dir=\"ltr\" style=\"font-size: 14px;\"><span dir=\"ltr\" style=\"font-size: 8pt; font-family: Roboto, sans-serif !important; font-weight: 400;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Push permission is already active on this device.</span></span></span></strong></div>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td dir=\"ltr\" style=\"width: 74.9123%; text-align: center;\"><span dir=\"ltr\" style=\"font-size: 10pt; font-family: Roboto, sans-serif !important; font-weight: 400;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Pop-up launched. User granted permission.</span></span>\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style=\"width: 74.9123%; text-align: center;\"><span dir=\"ltr\" style=\"font-size: 10pt; font-family: Roboto, sans-serif !important; font-weight: 400;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Push Notification Settings is enabled by default from OS below Android 12.</span></span>\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style=\"width: 74.9123%; text-align: center;\"><span dir=\"ltr\" style=\"font-size: 10pt; font-family: Roboto, sans-serif !important; font-weight: 400;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Push Notification Settings is ON.</span></span>\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td dir=\"ltr\" rowspan=\"2\" style=\"width: 25.0696%; text-align: center; font-size: 11.5pt !important; font-weight: 500 !important; font-family: Roboto, sans-serif !important;\">Fail\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t\t<td style=\"width: 74.9123%; text-align: center;\"><span dir=\"ltr\" style=\"font-size: 10pt; font-family: Roboto, sans-serif !important; font-weight: 400;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Pop-up launched. User denied SDK&#39;s custom popup permission.</span></span>\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style=\"width: 74.9123%; text-align: center;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Pop-up launched. User denied permission.</span>\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td dir=\"ltr\" style=\"width: 25.0877%; text-align: center; font-size: 11.5pt !important; font-weight: 500 !important; font-family: Roboto, sans-serif !important;\">Error\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t\t<td style=\"width: 74.9123%; text-align: center;\"><span dir=\"ltr\" style=\"font-size: 11pt; font-family: Roboto, sans-serif !important; font-weight: 400;\">Something went wrong with error --- &lt;error&gt;</span>\n\t\t\t\t<br>\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>"
}
[/block]