expo: Unrecognized permission: mediaLibrary

🐛 Bug Report

Summary of Issue

I have upgraded my expo sdk to the last one, and I am refactoring the permissions manager of my app. When asking for the permissions of the camera roll, I get the error “Unrecognized permission: mediaLibrary”

Environment - output of expo diagnostics & the platform(s) you’re targeting

Expo CLI 3.27.13 environment info: System: OS: Windows 10 10.0.19041 Binaries: Node: 12.18.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6241897 npmPackages: expo: ^40.0.0 => 40.0.0 react: ^16.13.1 => 16.14.0 react-dom: 16.11.0 => 16.11.0 react-native: ^0.63.4 => 0.63.4 react-native-web: ~0.13.7 => 0.13.18 Expo Workflow: managed

Reproducible Demo

Steps to Reproduce

Test the following code on iOS 14:

import { Camera as ExpoCamera } from "expo-camera";
import * as MediaLibrary from "expo-media-library";
import * as Permissions from "expo-permissions"; <--------

...
const [hasPermission, setHasPermission] = useState(null);

useEffect(() => { <------
   // TODO - Request CAMERA and CAMERA_ROLL permissions https://docs.expo.io/versions/latest/sdk/media-library/
   (async () => {
     const { status } = await Permissions.askAsync(
       Permissions.CAMERA,
       Permissions.MEDIA_LIBRARY
     );

     setHasPermission(status === "granted");
   })();
 }, []);

Expected Behavior vs Actual Behavior

How can I be able to ask media library permissions in the new sdk?

“expo-camera”: “~9.1.0”, “expo-media-library”: “~10.0.0”, “expo-permissions”: “~10.0.0”,

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (9 by maintainers)

Commits related to this issue

Most upvoted comments

we’ve moved away from using the Permissions module as the central way to request permissions and prefer calling the permissions requesters directly on the modules now.

so, MediaLibrary.requestPermissionsAsync() would be the solution here.

example: https://snack.expo.io/@brents/shallow-blueberries

that said, we should keep these old methods working or deprecate them

The same problem as @diegomais, I noticed, that MediaLibrary.getPermissionsAsync / MediaLibrary.requestPermissionsAsync always return {“status”: “undetermined”, “canAskAgain”: false, “expires”: “never”, “granted”: false} even if manually set up this permission READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE also added to Manifest

Expo eject to react native cli, all problem will be solved 😴, you can use all expo library there, just copy paste permission syntax…

Same issue, always get this:

{“status”: “undetermined”, “canAskAgain”: false, “expires”: “never”, “granted”: false}

Seems like we need an extra permission to be able to do this and it’s missing from the docs:

<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />

This solves it for me

When using MediaLibrary.saveToLibraryAsync(), I received the error: Missing MEDIA_LIBRARY write permission. Then I added MediaLibrary.requestPermissionsAsync() before saving the media, but I still got the error: Missing MEDIA_LIBRARY write permission.

The workaround was using ImagePicker.requestMediaLibraryPermissionsAsync().

It would be nice to also have MediaLibrary.requestMediaLibraryPermissionsAsync() so you don’t have to use a method from another package.

@CCB-cerivera FYI I heard Permissions module is deprecated. Try MediaLibrary.requestPermissionsAsync to get the permission.

Could someone help me, I’m on IOS 15.2 (simulator) and when requesting the MEDIA_LIBRARY permission it returns [granted] however when I use expo-media-library it returns the following error:

Error: MEDIA_LIBRARY permission is required to do this operation.

 "expo-media-library": "^12.1.2",
 "expo-permissions": "~10.0.0",

Permission routine:

const { status } = await Permissions.askAsync(Permissions.MEDIA_LIBRARY);

What is the solution here? I have hundreds of users getting Missing MEDIA_LIBRARY write permission..

Do I just request media permissions with ImagePicker.requestMediaLibraryPermissionsAsync()?

Using requestMediaLibraryPermissionsAsync seems to have fixed the issue for me on Android

any update on this?

Same here (Android 11 API 30), any updates on this? @brentvatne UPDATE Resolved on my side The issue was that I had another package which has <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" /> When I built app, AndroinManifest.xml was merged together and at the end I haven’t got permissions for using expo-media-library