Unified permissions API for React Native on iOS, Android and Windows platforms
—
Core functionality for checking the current status of device permissions. Returns status without requesting permission from the user.
Check the current status of a single permission without requesting it from the user.
/**
* Check the current status of a single permission
* @param permission - The permission to check
* @returns Promise resolving to the current permission status
*/
function check(permission: Permission): Promise<PermissionStatus>;Usage Examples:
import { check, PERMISSIONS, RESULTS } from "react-native-permissions";
// Check camera permission on iOS
const cameraStatus = await check(PERMISSIONS.IOS.CAMERA);
if (cameraStatus === RESULTS.GRANTED) {
console.log("Camera permission is granted");
} else if (cameraStatus === RESULTS.DENIED) {
console.log("Camera permission is denied");
} else if (cameraStatus === RESULTS.BLOCKED) {
console.log("Camera permission is permanently blocked");
}
// Check location permission on Android
const locationStatus = await check(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION);
console.log("Location permission status:", locationStatus);Check the status of multiple permissions in a single call, returning a mapped object with each permission's status.
/**
* Check the status of multiple permissions simultaneously
* @param permissions - Array of permissions to check
* @returns Promise resolving to object mapping each permission to its status
*/
function checkMultiple<P extends Permission[]>(
permissions: P
): Promise<Record<P[number], PermissionStatus>>;Usage Examples:
import { checkMultiple, PERMISSIONS, RESULTS } from "react-native-permissions";
// Check multiple iOS permissions
const statuses = await checkMultiple([
PERMISSIONS.IOS.CAMERA,
PERMISSIONS.IOS.MICROPHONE,
PERMISSIONS.IOS.PHOTO_LIBRARY,
]);
console.log("Camera:", statuses[PERMISSIONS.IOS.CAMERA]);
console.log("Microphone:", statuses[PERMISSIONS.IOS.MICROPHONE]);
console.log("Photo Library:", statuses[PERMISSIONS.IOS.PHOTO_LIBRARY]);
// Check if all permissions are granted
const allGranted = Object.values(statuses).every(status => status === RESULTS.GRANTED);
console.log("All permissions granted:", allGranted);
// Check specific Android permissions
const androidStatuses = await checkMultiple([
PERMISSIONS.ANDROID.CAMERA,
PERMISSIONS.ANDROID.RECORD_AUDIO,
PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,
]);Check the current location accuracy authorization level on iOS devices.
/**
* Check the current location accuracy authorization (iOS only)
* @returns Promise resolving to current location accuracy level
*/
function checkLocationAccuracy(): Promise<LocationAccuracy>;
type LocationAccuracy = 'full' | 'reduced';Usage Examples:
import { checkLocationAccuracy, PERMISSIONS, check } from "react-native-permissions";
// First ensure location permission is granted
const locationStatus = await check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
if (locationStatus === RESULTS.GRANTED) {
const accuracy = await checkLocationAccuracy();
if (accuracy === 'full') {
console.log("Full location accuracy available");
} else {
console.log("Reduced location accuracy - consider requesting full accuracy");
}
}Check notification permissions and get detailed settings for each notification type.
/**
* Check notification permissions and get detailed settings
* @returns Promise resolving to notification status and settings
*/
function checkNotifications(): Promise<NotificationsResponse>;
interface NotificationsResponse {
status: PermissionStatus;
settings: NotificationSettings;
}
interface NotificationSettings {
alert?: boolean;
badge?: boolean;
sound?: boolean;
carPlay?: boolean;
criticalAlert?: boolean;
provisional?: boolean;
providesAppSettings?: boolean;
lockScreen?: boolean;
notificationCenter?: boolean;
}Usage Examples:
import { checkNotifications, RESULTS } from "react-native-permissions";
const notificationResult = await checkNotifications();
console.log("Notification status:", notificationResult.status);
if (notificationResult.status === RESULTS.GRANTED) {
const { settings } = notificationResult;
console.log("Alert notifications:", settings.alert);
console.log("Badge notifications:", settings.badge);
console.log("Sound notifications:", settings.sound);
console.log("Lock screen notifications:", settings.lockScreen);
}
// Check if specific notification types are enabled
if (notificationResult.settings.alert && notificationResult.settings.sound) {
console.log("Both alert and sound notifications are enabled");
}All check functions return one of these permission status values:
type PermissionStatus = 'unavailable' | 'blocked' | 'denied' | 'granted' | 'limited';
// Available as constants:
declare const RESULTS: {
readonly UNAVAILABLE: 'unavailable'; // Permission not available on this platform
readonly BLOCKED: 'blocked'; // Permission permanently denied
readonly DENIED: 'denied'; // Permission denied but can be requested again
readonly GRANTED: 'granted'; // Permission granted
readonly LIMITED: 'limited'; // Permission granted with limitations (iOS)
};Check functions may throw errors in the following cases:
import { check, PERMISSIONS } from "react-native-permissions";
try {
const status = await check(PERMISSIONS.IOS.CAMERA);
console.log("Permission status:", status);
} catch (error) {
console.error("Failed to check permission:", error);
// Handle error appropriately
}Install with Tessl CLI
npx tessl i tessl/npm-react-native-permissions