When you build an Expo app, request permission before accessing
personal information or device features
. For example, opening the camera requires camera permission, and reading the user's location requires location permission.
Expo provides APIs for requesting these permissions. We'll walk through them using the Expo permissions guideโ as a reference.
Expo provides permission APIs through its individual modules. The original guide mentions expo-modules and the legacy expo-permissions package. The examples below use APIs from the relevant modules.
Check the current permission status.
Request permission when needed.
Decide what the app should do based on the result.
Here's a basic example.
import * as Location from 'expo-location';const getLocation = async () => { const { status } = await Location.requestForegroundPermissionsAsync(); if (status !== 'granted') { alert('์์น ๊ถํ์ด ํ์ํฉ๋๋ค.'); return; } const location = await Location.getCurrentPositionAsync({}); console.log(location);};
It requests location permission and reads the location only if the user grants it.
When requesting permission, tell the user which feature needs access and why. โWe need photo access so you can upload a pictureโ is more useful than โPermission required.โ Vague explanations can also cause problems during app store review.
Expo's permission APIs are straightforward, but iOS and Android have their own configuration requirements, and the timing and wording of a request matter to users.
Permission requests affect user trust. Make the purpose of each permission clear and ask only when access is needed. Adapt the examples above to the features in your app.