Vikas
Vikas

Reputation: 985

Opening Contacts app in react native

I am making a react native app and in one screen there is a form in which user has to fill the form in which the user has to fill his mobile number so I am making a button which will open the contacts app of the user phone and the user can select the conatct number from that list and that number gets filled in the field .

I found this link react-native-contacts but i think that it is taking all the contact Lists and displaying it in the react native app using List View but I do not want this type of functionality . I only want to open the contacts app and then if the user select any particular contact that should be filled in the mobile number field.

Code implementation

import ContactsWrapper from 'react-native-contacts-wrapper';
import { Separator, SeparatorDate } from '../../components/List';

export default class AddNewClub extends Component {


  constructor(props) {

    super(props);
    this.onMobileIconPressed = this.onMobileIconPressed.bind(this);

    this.state = {

      registerButtonClicked: false,


    };

  }

  registerButtonClick = () => {


    this.setState({
      registerButtonClicked: true,

    });

  };


  onMobileIconPressed() {
    ContactsWrapper.getContact()
    .then((contact) => {
        // Replace this code
        console.log(contact);
    })
    .catch((error) => {
        console.log("ERROR CODE: ", error.code);
        console.log("ERROR MESSAGE: ", error.message);
    });
}

This is the code which I have written and when I am testing this screen on device then it gives an error "unable to resolve module react-native-contacts-wrapper

Upvotes: 3

Views: 4634

Answers (2)

Muhammad Bin Naeem
Muhammad Bin Naeem

Reputation: 76

I had the same scenario but I didn't find any package which can open native contact list, therefore, I made a screen where I am getting all contacts in ListView.

Upvotes: 1

sourabh dadapure
sourabh dadapure

Reputation: 202

you can use react-native-contacts-wrapper

Upvotes: 1

Related Questions