React-native-contacts: App crash due to no permissions given on Android buildToolsVersion 25

Created on 18 Sep 2017  路  3Comments  路  Source: morenoh149/react-native-contacts

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.

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:

        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 []
            }
          })
        })

All 3 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dubbelnisse picture dubbelnisse  路  10Comments

DavidASix picture DavidASix  路  7Comments

salisaim picture salisaim  路  8Comments

sgithuku picture sgithuku  路  7Comments

suryaiiit picture suryaiiit  路  5Comments