Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add contact to the phone using react native?

Tags:

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

like image 211
hecontreraso Avatar asked Jan 05 '17 03:01

hecontreraso


2 Answers

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

like image 51
maulikdhameliya Avatar answered Sep 29 '22 09:09

maulikdhameliya


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

refer this link

like image 43
Santosh Sharma Avatar answered Sep 29 '22 11:09

Santosh Sharma