After upgrading to 36, cant seem to use CameraRoll without ejecting

Please provide the following:

  1. SDK Version: 36
  2. Platforms(iOS):

Howdy,
I have a component that uses CameraRoll.getPhotos(), using expo-permissions.
After upgrading to 36, CameraRoll isnt included in react-native anymore. When trying to use CameraRoll from @react-native-community/cameraroll, I get an error _nativeInterface.default.getPhotos is not defined.

According to their documentation, it appears you need to eject to avoid this error.

In Expo 35 I was able to getPhotos without having to eject.

Any help would be appreciated.

Heres my component:

export function AddMediaItem(props: AddMediaItemProps) {
  // ...
  useEffect(() => {
    ensurePermissions()
      .then(() => CameraRoll.getPhotos({
        assetType: 'Photos',
        first: 20,
        groupTypes: 'All',
      }));
  }, [ ]);
  const ensurePermissions = async () => {
    if (Constants && Constants.platform && Constants.platform.ios) {
      const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
      if (status === 'granted') {
        updateGrantedPermissions(true);
      }
    }
  };
  // ...
}

I had the same issue, but you can easily switch to https://docs.expo.io/versions/latest/sdk/media-library/

The API is close 1:1, you need just to change a little bit (took me 5 minutes). I have to admit that MediaLibrary fetches images slower as CameraRoll though.

2 Likes