react-native-permissions icon indicating copy to clipboard operation
react-native-permissions copied to clipboard

Media Library permission unavailable

Open jasonkang14 opened this issue 6 years ago • 5 comments

I am using the code below in order to check / request media library permission for iOS but it says that the feature is not available both in simulators and real devices. Am I missing something?

    if (Platform.OS === 'ios') {
      check(PERMISSIONS.IOS.MEDIA_LIBRARY)
        .then(result => {
          switch (result) {
            case RESULTS.UNAVAILABLE:
              console.log(
                'This feature is not available (on this device / in this context)',
              );
              break;
            case RESULTS.DENIED:
              console.log(
                'The permission has not been requested / is denied but requestable',
              );
              break;
            case RESULTS.GRANTED:
              console.log('The permission is granted');
              break;
            case RESULTS.BLOCKED:
              console.log(
                'The permission is denied and not requestable anymore',
              );
              break;
          }
        })
        .catch(error => {
          console.log('media library permission error');
        });
    }

jasonkang14 avatar Aug 14 '20 05:08 jasonkang14

@jasonkang14 Please respect the issue template, and submit your Podfile.

zoontek avatar Aug 14 '20 08:08 zoontek

same here. I already added media library ( same as other permissions) in Podfile though

jehee-choi avatar Aug 20 '20 08:08 jehee-choi

For me it works on the real device, but is unavailable in the simulator. Have you found a solution to get it working in the simulator?

fabyeah avatar Dec 18 '20 13:12 fabyeah

@fabyeah This is impossible: https://github.com/zoontek/react-native-permissions/blob/master/ios/MediaLibrary/RNPermissionHandlerMediaLibrary.m#L17

The only solution would be having a real emulator (the iOS simulator does not really emulate iOS, it has a lot of quirks) - see https://www.google.com/search?q=MPMediaLibrary+requestAuthorization+simulator&oq=MPMediaLibrary+requestAuthorization+simulator&aqs=chrome..69i57.3723j0j4&sourceid=chrome&ie=UTF-8

zoontek avatar Dec 18 '20 13:12 zoontek

@zoontek I see, that explains it. Thought it was a bug, but then it's all good. Thanks for the info!

fabyeah avatar Dec 19 '20 19:12 fabyeah