Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to getAllContacts on iOS 13 #79

Open
fpaaske opened this issue Nov 10, 2019 · 5 comments
Open

Unable to getAllContacts on iOS 13 #79

fpaaske opened this issue Nov 10, 2019 · 5 comments

Comments

@fpaaske
Copy link

fpaaske commented Nov 10, 2019

It seems that something is broken when using this library on iOS 13. The permission request pops up, and there are no error messages. But the response is always an empty list.

Same code on iOS 12 or below works fine.

To reproduce

tns create contacts-test --template tns-template-hello-world-ng
cd contacts-test
tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.2.0 version and is up to date.
✔ Component tns-core-modules has 6.2.0 version and is up to date.
✔ Component tns-android has 6.2.0 version and is up to date.
✔ Component tns-ios has 6.2.0 version and is up to date.
yarn add nativescript-contacts

add to Info.plist:

<key>NSContactsUsageDescription</key>
<string>Kindly provide permission to access contact on your device.</string>

add to items.component.ts

import { getAllContacts } from "nativescript-contacts";
<snip>
    ngOnInit(): void {
        this.items = this.itemService.getItems();
        getAllContacts().then(contacts => console.log(`got ${contacts.data.length} contacts`));
    }

Open multiple emulators from iOS 10 to iOS 13.

tns run ios --emulator

See that contacts.data.length is 0 for iOS 13.

@fpaaske
Copy link
Author

fpaaske commented Nov 18, 2019

@firescript do you know what could cause this issue, and if there's a workaround for iOS 13?

@liuy97
Copy link

liuy97 commented Nov 21, 2019

ios 13 has introduced new entitlement for accessing contacts, see details at https://stackoverflow.com/questions/57442114/ios-13-cncontacts-no-longer-working-to-retrieve-all-contacts

@fpaaske
Copy link
Author

fpaaske commented Dec 4, 2019

@liuy97 you are absolutely right. Removing request for notes solves the issue.
@firescript you should consider throwing some error with relevant information when this happens. Now it just fails silently.

@xaosaki
Copy link

xaosaki commented Jan 22, 2020

@mrpaaske
Hello, can you say what exactly should i do to get the result in getAllContacts? I'm new in nativescript and mobile applications.

UPD: I got it, in getAllContacts we should pass array of fields. And don't ask for notes field. Example: .getAllContacts(['name', 'phoneNumbers'])

@fpaaske
Copy link
Author

fpaaske commented Jan 23, 2020

@xaosaki that's exactly it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants