hecontreraso
hecontreraso

Reputation: 1290

How to add contact to the phone using react native?

I want to add to my application a button. So when is pressed, the phone's contacts application is opened, and the "Add contact" page is displayed with some data sent from the application.

How can I do that?

enter image description here

Update: After several weeks of investigation, I still have no idea about how to do this.

I tried with this library: https://github.com/rt2zz/react-native-contacts But it writes the contact directly to the contact list, without opening the contacts app.

Any help Will be super greatly appreciated

Upvotes: 5

Views: 9486

Answers (2)

Maulik Dhameliya
Maulik Dhameliya

Reputation: 1558

I am able to open native add to contact page using react-native-contacts.
link is here

Steps to do that

1. integrate react-native-contacts and make sure you follow all the steps and integrate correctly.
2. use below method to open it.

check openContactForm method of the library.

openContactPicker = () =>{
      let number="1234567890"; //replace with any number
      let newPerson = {
        phoneNumbers: [{
          label: "mobile",
          number: number,
        }],
      };

      Contacts.openContactForm(newPerson, (err) => {
        if (err) console.warn(err) ;
        // form is open
      });
  };

Note: contact we need to add should be a well-defined object that library recognizes. please check this

Upvotes: 3

Santosh Sharma
Santosh Sharma

Reputation: 2248

You Can Use wix-react-native-contacts npm package for your functionality.

refer this link

Upvotes: 2

Related Questions