2

I am attempting to request photo library access from the user in my react-native project I am experiencing an issue where it claims that I am not providing the permission handler in my Podfile I have these lines of code in my Podfile

permissions_path = '../node_modules/react-native-permissions/ios'

pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"

and as well as that, I have imported the relevant information into my Info.plist file

<key>NSPhotoLibraryUsageDescription</key>
<string>For choosing a photo</string>

and I am requesting the photos with a TouchableOpacity making a call to this asynchronous function

import {Platform} from 'react-native';
import {Permissions} from 'react-native-permissions';
...

const getPermission = async () => {
    if (Platform.OS !== 'web') {
      const {status} = Permissions.check(
      Permissions.IOS.PHOTO_LIBRARY,
      );
    return status;
  }
};
const addProfilePhoto = async () => {
    const {status} = await getPermission();

    alert('Status: ' + status);
};

Would appreciate if anyone notices an issue with my code. I am not using expo and would prefer not to be using it.

EDIT 1: I ended up reinitializing the project using npx react-native init and copied my source files over, excluding the ios folder. this seemed to work, and was probably an issue with my initial cocoapods setup.

0 Answers0