Reputation: 76
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
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