CodeBlanks Logo Icon CodeBlanks

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.

Practice Write checkPermission

Write a checkPermission function. It takes a status parameter. If status === 'granted' it returns true; otherwise false.

Starter code

App.js
// Write the checkPermission function
// Take status parameter; true if 'granted', else false

Sample solution

App.js
function checkPermission(status) {
  if (status === "granted") {
    return true;
  }
  return false;
}

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which needs a permission?

App.js
Permissions.askAsync(Permissions.CAMERA);
  • Showing Text
  • Using the camera Correct answer
  • Changing style
  • Pressing a button

Explanation: Using the camera needs a permission.

2 Camera without permission

Question
// Without permission the ____ can't open
Answer
// Without permission the camera can't open

Explanation: The camera cannot open without permission.

3 Match each concept to its role

Term Meaning
permission Approval gate
system dialog First request
camera Sensitive resource
deny No access

All lessons in Intermediate