React Native
What are permissions?
Learn the mobile app permissions concept.
What are permissions?
A permission is the operating system's approval gate for accessing a resource. Sensitive data like camera, location, notifications cannot be used by the app alone; the user must explicitly consent. The first request appears as a system dialog.
Permissions are required for security and privacy. Users do not want an app to access something without knowing. Once granted the app can use that resource; if denied it cannot. iOS and Android have slightly different permission flows; React Native and Expo wrap these differences under a common API with expo-permissions. This way one code works on both platforms.
The system dialog
When a permission is requested for the first time the operating system shows a system dialog. This dialog is controlled by the system, not the app; its design cannot be changed. The user picks 'Allow' or 'Deny'; this choice persists. Asking for the same permission again will not show the dialog; the last choice is remembered.
After a denial, asking again requires routing to settings. This is why a good flow asks for permission right at the moment of use, not before. Asking when the user taps 'Open camera' is less intrusive than asking at launch. This keeps user trust. If a permission is denied, showing an alternative message is also good.
Exercise Write checkPermission
Write a checkPermission function. It takes a status parameter. If status === 'granted' it returns true; otherwise false.
Show example solution
function checkPermission(status) {
if (status === "granted") {
return true;
}
return false;
}
Test yourself
-
Which needs a permission?
Permissions.askAsync(Permissions.CAMERA);
- Showing Text
- Using the camera
- Changing style
- Pressing a button
Show answer
Using the camera — Using the camera needs a permission.
-
Camera without permission
// Without permission the ____ can't open
Show answer
// Without permission the camera can't open
-
Match each concept to its role
- permission
- Approval gate
- system dialog
- First request
- camera
- Sensitive resource
- deny
- No access
Next lesson: expo-permissions