I am using React Native version 42 and asking permissions as below. But after allowing or denying the permissions, I am not seeing the status in console. According to documentation https://facebook.github.io/react-native/docs/permissionsandroid.html they say we can see the status in console. Can anybody help me what I am doing wrong. I want to print the status of granted but the line itself is not getting called.
componentDidMount() {
this.requestPermissions();
}
async requestPermissions() {
try {
const granted = await PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE, PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE])
console.log("permissions status: " +JSON.stringify(granted));
} catch (err) {
console.warn(err)
}
}
PermissionAndroid.requestMultiple returns a promise with permission status. Try like this
PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE, PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE]).then((result) => {
console.log('result', result);
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With