How to use the react-native-contacts.addContact function in react-native-contacts

To help you get started, we’ve selected a few react-native-contacts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rt2zz / react-native-contacts / example / src / index.js View on Github external
addContact () {
    let newContact = {
      givenName: PREFIX + Math.floor(Math.random()*99999999),
      familyName: PREFIX + Math.floor(Math.random()*99999999),
      emailAddresses: [
        {email: 'fromRNContacts1@example.com', type: 'work'},
        {email: 'fromRNContacts2@example.com', type: 'personal'}
      ]
    }
    Contacts.addContact(newContact, (err, data) => {
      Contacts.getAll((err, records) => {
        let contact = _.find(records, {givenName: newContact.givenName})
        console.log('attempted to add:', newContact)
        console.log('after add:', contact)
        _.each(newContact, (value, key) => {
          if (Array.isArray(newContact[key])) {
            invariant(
              contact[key].length === newContact[key].length,
              'contact values !isEqual for ' + key
            )
          } else {
            invariant(
              _.isEqual(contact[key], newContact[key]),
              'contact values !isEqual for ' + key
            )
          }
github radiegtya / BukanMessenger / app / screens / push / NewContact.js View on Github external
handleDone(validationCondition){
    const {firstName, lastName, mobileNumber} = this.state;
    if(validationCondition){
        RNContacts.addContact({
          givenName: firstName + " " + lastName,
          phoneNumbers: [
            {
              label: "mobile",
              number: mobileNumber
            }
          ]
        },(err)=>{
          if(!err){
            this.props.navigator.pop();
          }
        })
    }
  }