How to use the react-native-contacts.getAll 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 EdgeApp / edge-react-gui / src / modules / UI / components / ContactsLoader / actions.js View on Github external
return new Promise((resolve, reject) => {
    return Contacts.getAll((error, result) => {
      // The native code sometimes sends strings instead of errors:
      if (error) return reject(typeof error === 'string' ? new Error(error) : error)
      return resolve(result)
    })
  })
}
github radiegtya / BukanMessenger / app / screens / tabs / Contacts.js View on Github external
const ContactsContainer = createContainer((props) => {
  //get all phone contacts, then generate to contacts collection
  RNContacts.getAll((err, contacts) => {
    if(err === 'denied'){
      // x.x
    } else {
      let phoneNumbers = [];
      contacts.forEach((contact)=>{
        contact.phoneNumbers.forEach((phone)=>{
          if(phone.number){
            const formatedPhoneNumber = "+" + phone.number.replace(new RegExp(/[-\/\\^$*+?.()|[\]{}]/g, 'g'), '').replace(/\s/g,'');
            phoneNumbers.push(formatedPhoneNumber);
          }
        });
      });
      phoneNumbers = [...new Set(phoneNumbers)];
      Meteor.call('contacts.generate', phoneNumbers);
    }
  });
github rt2zz / react-native-contacts / example / App.js View on Github external
loadContacts() {
    Contacts.getAll((err, contacts) => {
      if (err === "denied") {
        console.warn("Permission to access contacts was denied");
      } else {
        this.setState({ contacts });
      }
    });
  }
github rt2zz / react-native-contacts / example / src / index.js View on Github external
deleteContact () {
    Contacts.getAll((err, contacts) => {
      let contactToDelete = _.find(
        contacts,
        (contact) => contact.givenName
          && contact.givenName.indexOf(PREFIX) === 0
      )
      if (!contactToDelete) {
        contactToDelete = contacts[0]
      }
      console.log('attempting to delete', contactToDelete)
      Contacts.deleteContact(contactToDelete, (err, data) => {
        Contacts.getAll((err, newContactList) => {
          console.log('resultant list', newContactList)
          invariant(
            newContactList.length === contacts.length -1,
            'getAll should return one less result'
          )
github rt2zz / react-native-contacts / example / src / index.js View on Github external
updateContact () {
    Contacts.getAll((err, data) => {
      console.log('data', data)
      let originalRecord = _.cloneDeep(data[0])
      let pendingRecord = _.cloneDeep(data[0])
      if (originalRecord.familyName) {
        pendingRecord.familyName = (
          originalRecord.familyName
          + Math.floor(Math.random() * 999999)
        ).slice(0, 20)
      } else {
        pendingRecord.familyName = '' + Math.floor(Math.random() * 999)
      }
      pendingRecord.emailAddresses.push({
        email: 'addedFromRNContacts@example.com',
        type: 'work'
      })
console.log('begin updateContact')
github rt2zz / react-native-contacts / example / src / index.js View on Github external
Contacts.deleteContact(contactToDelete, (err, data) => {
        Contacts.getAll((err, newContactList) => {
          console.log('resultant list', newContactList)
          invariant(
            newContactList.length === contacts.length -1,
            'getAll should return one less result'
          )
          invariant(
            !_.find(newContactList, {recordID: contactToDelete.recordID}),
            'contact should not longer exist'
          )
        })
      })
    })
github preposterousCloud / open-door / native / sharedNative / actions / actions.js View on Github external
export function getAllContacts(cb) {
  return Contacts.getAll((err, contacts) => {
    if (err && err.type === 'permissionDenied') {
      console.error('Nope!');
    } else {
      cb(contacts);
    }
  });
}
/** *****************************************************
github Skjutsgruppen / skjutsgruppen-reactnative / app / services / apollo / contact.js View on Github external
return new Promise((resolve) => {
    Contacts.getAll(async (error, contacts) => {
      if (error === 'denied') {
        resolve(contactList);
      }

      contacts.forEach(
        (contact) => {
          if (contact.phoneNumbers.length > 0) {
            const contactName = `${contact.givenName ? contact.givenName : ''}${contact.familyName ? ` ${contact.familyName}` : ''}`;

            contact.phoneNumbers.forEach(phoneBook =>
              contactList.push({
                name: contactName,
                phoneNumber: phoneBook.number,
              }),
            );
          }