How to request permission just using Expo?


#1

It seems requesting permission is not supported in Expo am I right?

I’ve seen checking permission in documents.
How can I request LOCATION permission to user when permission in not granted?

I don’t want to use rnpm or CRNA or detach the app.


#2

Use the Permissions API to ask for permissions: https://docs.expo.io/versions/latest/sdk/permissions.html. In SDK 18 this looks like:

async function getLocationAsync() {
  const { Location, Permissions } = Expo;
  const { status } = await Permissions.askAsync(Permissions.LOCATION);
  if (status === 'granted') {
    return Location.getCurrentPositionAsync({enableHighAccuracy: true});
  } else {
    throw new Error('Location permission not granted');
  }
}