firescript / nativescript-contacts

A nativescript module that gives access to the native contact directory.
MIT License
28 stars 32 forks source link

Not able to save a contact on iOS #47

Closed ashishwadekar closed 5 years ago

ashishwadekar commented 5 years ago

Hello,

First of all. Thanks for making this awesome plugin to make is very easy to manage contacts 🙌

I am having an issue while saving a new contact in Vue Nativwscript enivronment. I am able to successfully read contact as explained in the example.

Sharing the code here:

import * as ContactHelper from "nativescript-contacts";
import * as app from "application";

onContactButtonTap() {
      var contactBuilder = new ContactHelper.Contact();

      if (this.contactDetails.first_name) {
        contactBuilder.name.given = this.contactDetails.first_name;
      }

      if (this.contactDetails.last_name) {
        contactBuilder.name.family = this.contactDetails.last_name;
      }
      contactBuilder.save();
}

Added the Privacy - Contact key in info.plist:

<key>Privacy - Contacts Usage Description</key>
        <string>Kindly provide permission to save selected contact to phone.</string>

Can you help me in getting this to work? Thanks.

Cheers, Ashish

ashishwadekar commented 5 years ago

Ok. So the key in info.plist was wrong. Added the right one & everything was working fine.

I am sharing a PR with the instructions added & Single User Data Structure & Address structure with minor corrections.

Cheers.