react-native-contacts
react-native-contacts copied to clipboard
iOS permissions issue
Permissions promise is not completing, nor is it triggering a permissions request on the device for iOS 18. All the correct permissions have been stated in the Info.plist. This was working in previous versions.
Please let me know if you require any additional info to resolve this.
I am experiencing this issue as well. The code works perfectly on versions lower than 18.0. However, on versions 18.0 and above, neither the then nor the catch block executes, and no console log is printed.
Contacts.checkPermission() .then((permission) => { console.log(permission); }) .then((err) => { console.log(err); });
A work around we have found is to use react-native-permissions to request permissions from the user and then use react-native-contacts to retrieve the contact data. I hope this helps.
This issue is stale, please provide more information about the status
Facing the same issue on iOS v18.3.1
A work around we have found is to use react-native-permissions to request permissions from the user and then use react-native-contacts to retrieve the contact data. I hope this helps.
This worked for me.
Hi @Kushagra-ag and @MydusApps, just curious, do you all remember if it reproduced 100% of the time on any iOS 18+ ? I am debugging a similar issue, but I can't seem to repro this issue on my personal iOS v18.3.1 device. Thank you!
Not sure what the issue is
Currently having the same issue, on iOS 18.4, RN 0.79.2 and release 8.0.5, calling
Contacts.checkPermission().then((permission) => {}) won't trigger the promise
and can't even log the permission var. Also worked for me in previous versions.
Same issue here, I see the: NSContactsUsageDescription in the info.plist but doesn't it get triggered.
Same issue. Contacts.checkPermission() hangs when called and never completes.
A work around we have found is to use react-native-permissions to request permissions from the user and then use react-native-contacts to retrieve the contact data. I hope this helps.
Did any1 resolved it?
I can't use react-native-permissions latest version as it requires xcode 16 to make the ios builds, but i'm targeting ios12+ builds.....i thought this library had a work around for this limited contact's permission check issue (feature in ios18+), but it too has a bug.
Tested this on ios 18.4 simulator (xcode 16.2) @morenoh149 @x64Eddie
It was fixed in this pull request, but I see it didn't get released yet.
Basically method which check permission doesn't have a resolve call if ios version is greater than 18.0. After applying a patch with this change, issue was fixed for me
@trizerr Contacts.checkPermission() still hangs for me and never resolves, even though this code is present in 8.0.5
And Contacts.requestPermission() returns undefined, even though I've set limited access in settings 😔
The latest release does not work for me. I resolved it by updating RCTContacts.m to this:
Line 56:
RCT_EXPORT_METHOD(checkPermission:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock) __unused reject)
{
CNAuthorizationStatus authStatus = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
if (authStatus == CNAuthorizationStatusDenied || authStatus == CNAuthorizationStatusRestricted) {
resolve(@"denied");
} else if (authStatus == CNAuthorizationStatusAuthorized) {
resolve(@"authorized");
} else if (@available(iOS 18, *)) {
if (authStatus == CNAuthorizationStatusRestricted || authStatus == CNAuthorizationStatusLimited) {
resolve(@"limited");
} else {
resolve(@"undefined");
}
} else {
resolve(@"undefined");
}
}
Line 1660
- (void)checkPermission:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
CNAuthorizationStatus authStatus = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
if (authStatus == CNAuthorizationStatusDenied || authStatus == CNAuthorizationStatusRestricted) {
resolve(@"denied");
} else if (authStatus == CNAuthorizationStatusAuthorized) {
resolve(@"authorize");
} else if (@available(iOS 18, *)) {
if (authStatus == CNAuthorizationStatusRestricted || authStatus == CNAuthorizationStatusLimited) {
resolve(@"limited");
} else {
resolve(@"undefined");
}
} else {
resolve(@"undefined");
}
}
I solved it by replacing Contacts.checkPermission() with:
Promise.race([
Contacts.checkPermission(),
new Promise(resolve => {
setTimeout(() => resolve('undefined'), 1500)
}),
])
This adds a timeout in a race of promises, and resolves to 'undefined' if the original function doesn't resolve in 1,5 sec.