[expo-media-library] get/request permission always returns undetermined / denied

See original GitHub issue

Summary

MediaLibrary.getPermissionsAsync() always returns status:undetermined when granted(denied when denied), and when canAskAgain:true, requestPermissionsAsync() always returns granted:false immediately without asking.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

43.0.3

Environment

Expo CLI 4.13.0 environment info: System: OS: macOS 11.6 Shell: 5.8 - /bin/zsh Binaries: Node: 12.19.0 - /usr/local/bin/node Yarn: 2.4.2 - /usr/local/bin/yarn npm: 8.1.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 IDEs: Android Studio: 4.1 AI-201.8743.12.41.6858069 Xcode: 13.0/13A233 - /usr/bin/xcodebuild npmPackages: expo: ^43.0.3 => 43.0.3 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: expo-cli: 4.13.0 Expo Workflow: bare

Reproducible demo or steps to reproduce from a blank project

install bare workflow project, add dependencies expo 43.0.3, expo-media-library

let permission = await MediaLibrary.getPermissionsAsync(); if (!permission.granted) { if (permission.canAskAgain || permission.status === “undetermined”) { permission = await MediaLibrary.requestPermissionsAsync(false); if (!permission.granted) { //denied return; } } else { //denied return; } }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:37 (6 by maintainers)

github_iconTop GitHub Comments

16reactions
iKorucommented, Nov 25, 2021

@emmbyiringiro thanks for your comment. But it doesn’t work as we want, unfortunately. EVEN THOUGH access is allowed in android settings, the return value for the function getPermissionAsync is

{granted:false, canAskAgain:false, status:"undetermined"}

when I expect as follows : {granted:true, canAskAgain:false, status:"granted"}

10reactions
hanhui870commented, Dec 25, 2021

Same issue. my project ejected. Add <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /> to src/main/AndroidManifest.xml, then it behaved as expected

Read more comments on GitHub >

github_iconTop Results From Across the Web

MediaLibrary - Expo Documentation
Check or request permissions to access the media library. This uses both requestPermissionsAsync and getPermissionsAsync to interact with the permissions.
Read more >
Expo Background Permissions Async is not working
1 Answer 1 · Location.requestBackgroundPermissionsAsync() Asks the user to grant permissions for location while the app is in the background.
Read more >
@boythan/react-native-permissions - npm package | Snyk
Methods ; request(), type, - Accepts any permission type except backgroundRefresh . If the current status is undetermined , shows the permission dialog...
Read more >
PermissionsAndroid - React Native
Prompts the user to enable a permission and returns a promise resolving to a string value (see result strings above) indicating whether the...
Read more >
expo-permissions is now deprecated - You.com - You.com
React Native expo-permission deprecated what to use now? ... 'granted') { console.log('Permission to access location was denied'); return; }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found