React Native Permissions

5.5.1 · active · verified Tue Apr 21

react-native-permissions provides a unified, cross-platform API for managing user permissions on iOS, Android, and Windows within React Native applications. It abstracts away the platform-specific nuances of checking and requesting permissions like camera, location, and notifications, offering a consistent interface. The current stable version is 5.5.1. The library follows the React Native release support policy, supporting the latest version and the two previous minor series, indicating a regular update cadence aligned with React Native itself. A key differentiator is its modular iOS setup, where developers explicitly enable only the permissions they need via a `Podfile` script, reducing the app's binary size and simplifying configuration, alongside robust TypeScript support and handling of nuances like Android's one-time permissions. It supports Windows builds 18362 and later, extending its reach beyond mobile.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates checking and requesting camera permission, handling different statuses across iOS and Android.

import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions';
import { Platform, Alert } from 'react-native';

const getCameraPermission = async () => {
  let permission;
  if (Platform.OS === 'ios') {
    permission = PERMISSIONS.IOS.CAMERA;
  } else if (Platform.OS === 'android') {
    permission = PERMISSIONS.ANDROID.CAMERA;
  } else {
    Alert.alert('Unsupported platform');
    return;
  }

  try {
    let result = await check(permission);
    if (result === RESULTS.DENIED) {
      result = await request(permission);
    }

    if (result === RESULTS.GRANTED) {
      Alert.alert('Camera permission granted!');
    } else if (result === RESULTS.BLOCKED) {
      Alert.alert('Camera permission blocked', 'Please go to settings to enable camera.');
    } else {
      Alert.alert('Camera permission status: ' + result);
    }
  } catch (error) {
    console.error('Permission check failed', error);
    Alert.alert('Error requesting permission');
  }
};

// Call this function from a component or an event handler
// getCameraPermission();

view raw JSON →