---
title: "Handle permission requests in flows - React Native"
description: "Ask users for push notification permission from a flow in your React Native app with the onRequestPermission handler, and return their answer to the flow."
---

> **AI agents**: to search Adapty docs faster and with fewer tokens, install the Adapty skills: `npx adapty skills install --yes`

A [flow](adapty-flow-builder) can ask users for permission to send push notifications with the **Request permission** action, for example on an onboarding screen that explains what the notifications are for. The Adapty SDK doesn't show the system permission dialog itself. It passes the request to the `onRequestPermission` handler in your app. Your app shows the dialog and returns the user's answer, and the flow continues.

## Before you start

You need:

- **Adapty React Native SDK 4.0.0 or later**: Earlier versions don't have the `onRequestPermission` handler.
- **A flow with the Request permission action**: In the Flow & Paywall Builder, add the **Request permission** action to an element's **On Tap** or **On Screen Appear** trigger. In its **After response** section, add the actions to run after the user answers, such as **Navigate Next**. For the action settings, see [Request permission](onboarding-actions#request-permission).
- **A library that shows the notification dialog**: The example uses [react-native-permissions](https://github.com/zoontek/react-native-permissions). To set it up, follow its [setup guide](https://github.com/zoontek/react-native-permissions#setup), and add `Notifications` to the iOS permissions it sets up. Any other library that shows the dialog works too, for example `expo-notifications` in an Expo app.
- **The `POST_NOTIFICATIONS` permission in your Android manifest, and `targetSdk` 33 or higher**: Android 13 and later show the notification permission dialog only to apps that declare the permission and target Android 13 or later:

  ```xml title="android/app/src/main/AndroidManifest.xml"
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
  ```

## How the flow requests a permission

1. The flow reaches the **Request permission** action: the user taps the element, or the screen appears.
2. The Adapty SDK calls your `onRequestPermission` handler with the permission `push`.
3. Your app shows the system dialog and resolves the handler's promise to `{ status: 'granted' }` or `{ status: 'denied' }`.
4. The flow runs the **After response** actions. They are the same for both answers.

The flow waits on the screen until your handler's promise resolves. If the promise never resolves, the flow stays on the screen. If the OS doesn't show the dialog, for example because the user already answered it, `requestNotifications` returns the earlier answer at once, and the flow runs the **After response** actions right away. If those actions leave the screen, the user sees the screen that requests the permission only for a moment.

With **On Screen Appear**, the flow doesn't send the request again when the user comes back to the screen with a **Navigate back** action. With **On Tap**, every tap sends a new request, except taps while a request waits for your answer.

## Implement the handler

The `onRequestPermission` handler is asynchronous, unlike the other flow handlers. It returns a promise that resolves to an object with the user's answer:

```typescript showLineNumbers title="permissions.ts"
import { requestNotifications } from 'react-native-permissions';
import type { FlowEventHandlers } from 'react-native-adapty';

export const onRequestPermission: FlowEventHandlers['onRequestPermission'] = async (permission) => {
  if (permission !== 'push') {
    // Answer every request: the flow waits on the screen until it gets the answer.
    return { status: 'denied' };
  }

  // Shows the system dialog, or returns the earlier answer without showing it.
  const { status } = await requestNotifications(['alert', 'badge', 'sound']);
  return { status: status === 'granted' ? 'granted' : 'denied' };
};
```

`onRequestPermission` receives:

- **`permission`**: The permission the flow requests. The **Request permission** action sends `push`.
- **`customArgs`**: Custom arguments of the request. The **Request permission** action sends none, so the object is empty.

The promise resolves to an object with these properties:

- **`status`**: The user's answer: `granted` if the user allowed the permission, and `denied` otherwise.
- **`detail`**: Optional. A string with more information about the answer, such as the status the library returned.

The Adapty SDK answers `denied` when your handler throws an error or its promise rejects.

A granted permission lets your app show notifications. To receive push notifications, register the device with your push provider, as your app does outside flows.

## Register the handler

:::warning
**Without an `onRequestPermission` handler, the user is never asked.** On a flow view without the handler, the Adapty SDK answers `denied` without a dialog and writes a warning to its log, and the flow runs the **After response** actions right away.
:::

Set the handler on every flow view your app creates. Flow authors can add the **Request permission** action to any flow later, without an app update, and a flow view without the handler answers `denied` without asking the user.

<Tabs groupId="presentation-method" queryString>
<TabItem value="platform" label="React component" default>

Pass the handler to the `onRequestPermission` prop of `AdaptyFlowView`:

```typescript showLineNumbers title="React Native (TSX)"
import React from 'react';
import { StyleSheet } from 'react-native';
import { AdaptyFlowView, type AdaptyFlow } from 'react-native-adapty';
import { onRequestPermission } from './permissions';

function MyFlow({ flow }: { flow: AdaptyFlow }) {
  return (
    <AdaptyFlowView
      flow={flow}
      style={StyleSheet.absoluteFill}
      onRequestPermission={onRequestPermission}
    />
  );
}
```

</TabItem>
<TabItem value="standalone" label="Modal presentation">

Register the handler with `setEventHandlers` before you present the view:

```typescript showLineNumbers title="React Native"
import { createFlowView } from 'react-native-adapty';
import { onRequestPermission } from './permissions';

const view = await createFlowView(flow);

view.setEventHandlers({
  onRequestPermission,
});

await view.present();
```

</TabItem>
</Tabs>

## Test the permission request

iOS shows the notification dialog only once per app install. Android stops showing it after the user allows notifications or denies them twice. To see the dialog again while you test the flow, delete the app from the device and install it again. Then open the flow and reach the **Request permission** action. If the flow moves on without a dialog, make sure that the flow view has the `onRequestPermission` handler, and that the Android app declares `POST_NOTIFICATIONS` and targets Android 13 or later.