How to Creating new Contact - addContactAsync


#1

Hi, I’m trying to add a new contact to my contacts on the phone. I’m using expo Contacts framework and it is working when I only add the first name, last name, company, position and note but when I add email and phone number the app crash. I read the documentation but I think something is missing in my code. can someone help me? Thanks!

const phoneDict = {
          id:'001223',
          label: 'labelX',
          number: '00033',
          countryCode :'+386',
          digits : '000333',
          isPrimary: true
        }

        const emailDict = {
            email : "test@gmail.com",
            isPrimary: true
          }

      const contact = {
        [Contacts.Fields.FirstName]: firstname,
        [Contacts.Fields.LastName]: lastname,
        [Contacts.Fields.Company]: company,
        [Contacts.Fields.JobTitle]: position,
        [Contacts.Fields.Note]: 'Contact from App.',
        [Contacts.Fields.Emails]: emailDict
        [Contacts.Fields.PhoneNumbers]: phoneDict
      }

      const contactId = await Contacts.addContactAsync(contact);