Adding new contact in ios

I am unable to add contact in ipad i have used addcontactasync. For some reason the firstName and LastName gets added but the phoneNumber is not getting added can someone say what syntax to use.
I have used [Contacts.Fields.phoneNumber]:this.state.phone

Hi @akhilnayak,

The field for phone number is actually phoneNumbers and it’s supposed to be provided an array. You can read about the fields in the Contact type here

Good luck!

@charliecruzan, Thank You for your help.
Here is my code:
const contact = {
[Contacts.Fields.FirstName]: this.state.firstName,
[Contacts.Fields.LastName]: this.state.lastName ,
[Contacts.Fields.PhoneNumbers]: [{ label : “mobile”,
number: this.state.phone
}]
}
try{
const contactId = await Contacts.addContactAsync(contact);
console.log(“contact-ID:”,contactId);
if(contactId){
alert(“Contact Saved.”)
}
else{
alert(“Contact not saved.”)
}}
catch(err){
alert(“Contact not Saved”)
}
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.