Although I declared permissions in the AndroidManifest.xml, the app crashes because I upgraded all dependencies to the buildToolsVersion 25 which (apparently) asks for permissions when inside the app by dialog on a relevant action.
As react-native-contacts doesn't show dialogs and the AndroidManifest.xml is not likely 'accepted', the app is crashing as soon as I try to access the contacts. I can handle exception but still, it doesn't solve the inability to access contacts.
Please help or share a workaround.
This can be worked around by using PermissionsAndroid: https://facebook.github.io/react-native/docs/permissionsandroid.html
Our code looks like this:
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
'title': 'Contacts',
'message': 'This app would like to view your contacts.'
}
).then(() => {
Contacts.getAll((err, contacts) => {
if(err === 'denied'){
// error
} else {
// contacts returned in []
}
})
})
@gulshanzealous faced the same issue @dabit3's solution fixed it..then i read the react native docs its mentioned that these are dangerous permissions so they need explicit permissions from user from android api version 23
https://facebook.github.io/react-native/docs/permissionsandroid.html
So is this now required for all modern versions of Android?
Most helpful comment
This can be worked around by using PermissionsAndroid: https://facebook.github.io/react-native/docs/permissionsandroid.html
Our code looks like this: