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 MediaLibrary - Expo Documentation

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

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.