Marius
Marius

Reputation: 76

CameraRoll on Android

Is there anybody who used the CameraRoll API for Android devices? Is Android supported ? I used the example from the docs, but it's not working.

Thanks in advance.

Upvotes: 3

Views: 3744

Answers (2)

Pablo Navarro
Pablo Navarro

Reputation: 452

You have to request the permission for that. Call a function like the one below (on your react-native project) and call it if your app runs on Android (Platform.OS === 'Android' ? this.requestPhotosPermission() : this.getPhotos())

import { PermissionsAndroid } from 'react-native'

async requestPhotosPermission() {
  try {
    const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE)
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        this.getPhotos();
      } else {
        console.log("Photos permission denied")
      }
  } catch (err) {
    console.warn(err)
  }
}

Upvotes: 3

Kishan Gujarati
Kishan Gujarati

Reputation: 985

Try this...

it is worked for me

CameraRollExample

Upvotes: 1

Related Questions