How do you manage permissions in React Native?

← React Native answers

Declare each permission natively (Info.plist on iOS, AndroidManifest.xml on Android), then request it at runtime, with PermissionsAndroid for Android or react-native-permissions for both.

  • iOS: add a usage description such as NSCameraUsageDescription to Info.plist, or the app crashes when it asks.
  • Android: add <uses-permission android:name="android.permission.CAMERA" /> to AndroidManifest.xml.
  • Android 6 and later also need a runtime request for dangerous permissions.
import { PermissionsAndroid, Platform } from 'react-native';
 
async function requestCamera(): Promise<boolean> {
  if (Platform.OS !== 'android') return true;     // iOS asks when the camera first opens
 
  const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA, {
    title: 'Camera access',
    message: 'The app needs the camera to scan codes.',
    buttonPositive: 'Allow',
    buttonNegative: 'Not now',
  });
  return result === PermissionsAndroid.RESULTS.GRANTED;
}

For one API across both platforms, react-native-permissions offers check and request with results such as granted, denied and blocked. Explain why you need a permission before asking, and handle the blocked state by sending the user to Settings, because the system will not ask again.

Related questions

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required