1

I want to take a picture in my Android app and save it to the camera roll. I'm using CameraRoll and RNCamera but the image is nowhere to be seen in the camera roll.

The function is:

...
import { RNCamera } from "react-native-camera";
import { CameraRoll } from "react-native";
...

async _takePicture() {
    const data = await this.camera.takePictureAsync({
      quality: 1.0,
      base64: true,
      orientation: "portrait",
      fixOrientation: true
    });
    CameraRoll.saveToCameraRoll(data.uri, "photo");
  }
...

Edit: I solved it by adding

const granted = await PermissionsAndroid.request(
              PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
              {
                title: 'My App Storage Permission',
                message: 'My App needs access to your storage ' +
                  'so you can save your photos',
              },
            );

after CameraRoll.saveToCameraRoll(data.uri, "photo");

Alejandro
  • 105
  • 7

0 Answers0