react-native-contacts: iOS 13 - Contacts.getAll returns empty array
After upgrading XCode to 11-beta and launching my app on simulator with iOS 13 - Contacts.getAll returns an empty array, on iOS 12 I had an array with contacts. Contacts permissions are granted to application
import Contacts from 'react-native-contacts';
const contacts =
yield new Promise((resolve, reject) => {
Contacts.getAll((err, result) => {
console.log('err', err); // ----> null
console.log('result', result); // ----> [] on iOS 13; array with contacts on iOS 12
return !err ? resolve(result) : reject(err)
});
});
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
@morenoh149 You misunderstood me. I am not asking you to do anything with my fork, that was just an easy way out for any users that struggle with this issue (not everyone can just upgrade RN 🙂).
What I meant to say is that all that is needed to do is to create release 4.0.3 of RNC, which would be based on release 4.0.2, just with cherry-picked commit from version 5.0.4 (the commit which fixes this issue). This will provide support for RN<0.60, because currently the library itself is unusable for those versions on iOS 13.
As I said, I am happy to contribute to fix this problem, but this is not something that has to do with coding, just with maintaining the library. You can basically do this just by running these commands:
And 🎉, you just published 4.0.3 that is available to anyone with RN under 0.60.
@Olovorr nice. I followed your instructions. I think if anyone is on a legacy rn version they could find this issue and get the fix. I know not everyone can update their rn but sometimes its good to get pressure to update your deps.
For future reference, if ppl want fixes and things like that, submit the PRs and tell me what commands to run to publish bugfixes to older versions.
I found temporary solution.
According to information about iOS 13 - it deprecated access to “Notes” key from contacts - in a reason of security: https://techcrunch.com/2019/06/05/with-ios-13-apple-locks-out-apps-from-accessing-users-private-notes-in-contacts/
I tried to remove all “notes” references from RCTContacts.m from RCTContacts.xcodeproj library and it seems started working. I`ve created patch for react-native-contacts module:
@ttDemon install rnc 4.0.3
@morenoh149 Hope you are interested in projects RN under 0.60. I really couldn’t upgrade my project. I am using RN 0.59x
@pmarconi yep. update your project to rn 60 first then use the latest rnc.