react-native-contacts icon indicating copy to clipboard operation
react-native-contacts copied to clipboard

iOS permissions issue

Open MydusApps opened this issue 1 year ago • 11 comments

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.

MydusApps avatar Dec 06 '24 09:12 MydusApps

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); });

C0zmaCatalin avatar Dec 19 '24 09:12 C0zmaCatalin

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.

MydusApps avatar Dec 19 '24 10:12 MydusApps

This issue is stale, please provide more information about the status

github-actions[bot] avatar Feb 18 '25 00:02 github-actions[bot]

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.

Kushagra-ag avatar Mar 13 '25 06:03 Kushagra-ag

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!

x64Eddie avatar Apr 05 '25 01:04 x64Eddie

Not sure what the issue is

morenoh149 avatar Apr 23 '25 23:04 morenoh149

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.

vvroul avatar May 15 '25 09:05 vvroul

Same issue here, I see the: NSContactsUsageDescription in the info.plist but doesn't it get triggered.

Lewitje avatar May 19 '25 10:05 Lewitje

Same issue. Contacts.checkPermission() hangs when called and never completes.

captnseagraves avatar May 22 '25 18:05 captnseagraves

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

xansrakshit avatar May 29 '25 08:05 xansrakshit

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

Image

trizerr avatar Jun 06 '25 20:06 trizerr

@trizerr Contacts.checkPermission() still hangs for me and never resolves, even though this code is present in 8.0.5

Image

And Contacts.requestPermission() returns undefined, even though I've set limited access in settings 😔

technoch1ef avatar Jul 24 '25 19:07 technoch1ef

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");
    }
}

pang0018 avatar Jul 27 '25 00:07 pang0018

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.

jgivoni avatar Sep 30 '25 14:09 jgivoni