{"library":"react-native-permissions","title":"React Native Permissions","description":"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install react-native-permissions"],"cli":null},"imports":["import { request } from 'react-native-permissions';","import { check } from 'react-native-permissions';","import { PERMISSIONS } from 'react-native-permissions';","import { RESULTS } from 'react-native-permissions';","import { Platform } from 'react-native';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions';\nimport { Platform, Alert } from 'react-native';\n\nconst getCameraPermission = async () => {\n  let permission;\n  if (Platform.OS === 'ios') {\n    permission = PERMISSIONS.IOS.CAMERA;\n  } else if (Platform.OS === 'android') {\n    permission = PERMISSIONS.ANDROID.CAMERA;\n  } else {\n    Alert.alert('Unsupported platform');\n    return;\n  }\n\n  try {\n    let result = await check(permission);\n    if (result === RESULTS.DENIED) {\n      result = await request(permission);\n    }\n\n    if (result === RESULTS.GRANTED) {\n      Alert.alert('Camera permission granted!');\n    } else if (result === RESULTS.BLOCKED) {\n      Alert.alert('Camera permission blocked', 'Please go to settings to enable camera.');\n    } else {\n      Alert.alert('Camera permission status: ' + result);\n    }\n  } catch (error) {\n    console.error('Permission check failed', error);\n    Alert.alert('Error requesting permission');\n  }\n};\n\n// Call this function from a component or an event handler\n// getCameraPermission();","lang":"typescript","description":"Demonstrates checking and requesting camera permission, handling different statuses across iOS and Android.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}