How to use the expo-permissions.Permissions.CAMERA_ROLL function in expo-permissions

To help you get started, we’ve selected a few expo-permissions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-asset-utils / example / getGalleryImageAsync.js View on Github external
export default async () => {
  const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
  if (status !== 'granted') {
    alert('failed to get library asset, please enable and restart demo');
    return;
  }
  const { edges } = await CameraRoll.getPhotos({ first: 1 });
  const assets = edges.map(({ node: { image } }) => image.uri);
  if (assets.length === 0) {
    alert("Looks like you don't have any photos in your gallery :[");
  }
  return assets[0];
};