React-native-contacts: Instant permissionDenied

Created on 29 Jun 2016  路  10Comments  路  Source: morenoh149/react-native-contacts

I'm getting the permissionDenied when doing getAll on iOS, works great on Andriod.

Error message:
{ type: 'permissionDenied' }

This is the code:

Contacts.getAll((err, contacts) => {
      if(err && err.type === 'permissionDenied'){
        dispatch(receiveContactsError())
      } else {
        dispatch(receiveContacts(contacts))
     }
})

Is this an know issue?

bug

Most helpful comment

I'm having the same issue.

Contacts.checkPermission( (err, permission) => {
        console.log(permission);
        if(permission === 'denied'){
          Contacts.requestPermission((error,permission)=>{
            console.log(error,permission)
          });
        }
  });
{ error : null,
permission : 'denied' }

It never requests for Contacts and denies straight away. If I try getAll(), it crashes the app.

All 10 comments

First report.

Could it be iOS or react-native version problems?

not likely. But I just merged a PR and published a new npm version so you should test that out.

Did't work with new version. I've tried checkPermission and requestPermission but it goes straight to denied anyway.

@dubbelnisse it sounds like you denied the contacts permission at some point in the past. If this is the case you will need to manually toggle it back on in the settings app.

I have the opposite problem. Works fine in the phone simulator for xcode, but is denied instantly on android.

I'm having the same issue.

Contacts.checkPermission( (err, permission) => {
        console.log(permission);
        if(permission === 'denied'){
          Contacts.requestPermission((error,permission)=>{
            console.log(error,permission)
          });
        }
  });
{ error : null,
permission : 'denied' }

It never requests for Contacts and denies straight away. If I try getAll(), it crashes the app.

If you're having an issue with iOS could you try my fork out https://github.com/npomfret/react-native-contacts/commits/master. Sorry but I've not upgraded to RN-40+ yet so the headers may need to be changed if you have.

I'm made every method check the health of the contacts store object before using it, and return an auth code style error if it's not healthy. I've also upgraded the remaining methods that were using the old AB API to use the new one.

Note that the getAll method no longer lazily requests permissions (so it behaves in a consistent manner to the others).

Im getting the same on android..

We now recommend using https://facebook.github.io/react-native/docs/permissionsandroid.html please report back if that works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgithuku picture sgithuku  路  7Comments

prathd picture prathd  路  5Comments

luism3861 picture luism3861  路  9Comments

farrukhhashmi65 picture farrukhhashmi65  路  7Comments

DavidASix picture DavidASix  路  7Comments