medialibrary getAlbumsAsync is undefined

#1

I’m trying to get access to media albums, and photos using Expo, this is the code I’m using

import { MediaLibrary, Permissions } from 'expo'

// I ask permissions
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL)
this.setState({ permissionsGranted: status === 'granted' }, this.getAlbums)

// if permissions granted
const albumsReponse = await MediaLibrary.getAlbumsAsync()

if I try to console.log MediaLibrary, I get undefined, also I get this error:

versions: expo: 27.0.1 react: 16.2.0 react-native: 0.52.0

#2

I made an example of using MediaLibrary, based on your code, using Snack.

https://snack.expo.io/@ccheever/medialibrary-example

#3

Thank you very much, I got the error, it was that I wasn’t using the forked version of react-native from Expo. and also on app.json I had an old version of Expo

closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.