Luigi Russo
Luigi Russo

Reputation: 23

Nativescript contact permission on iOS

I'm having troubles in order to let my NativeScript app read contacts on iOS. I'm using the library nativescript-contacts in order to read all the entries of the address book and the one called nativescript-permission in order to ask the user the permission to read contacts. Unfortunately, the latter seems to work only in Android, where everything works fine: a pop-up appears asking the user to allow the reading of contacts and, if the permission is granted, the contacts are displayed in a list. In iOS instead, I'm not able to ask for contact permission: no dialog box pops out and when I try to use a function of nativescript-contacts (e.g. getAllContacts()), the app freezes.

I've tried searching, but the only thing I can do seems to use some native code in order to get these permissions... but I have no idea how. May you help me with this?

Thanks!

Upvotes: 2

Views: 1264

Answers (1)

Robert D. Mogos
Robert D. Mogos

Reputation: 910

There are two things you might need:

1st, did you add in the Info.plist file a message for the key Privacy: Contacts usage description ? This will display the message you set to the user when prompted the permission alert.

2nd. You can ask for the permission by calling requestAccess(for:completionHandler:). Check this

Upvotes: 3

Related Questions