Skip to content Skip to sidebar Skip to footer

React-native-contacts Getall Return Null

according to this link I used react-native-contact to open contact list in android device so the user can choose one and and add it to list. but when I click a button to open a con

Solution 1:

One reason could be you didn't link the react-native-contact properly

You must also follow these steps to link-

For Android: https://github.com/rt2zz/react-native-contacts#android

For IOS: https://github.com/rt2zz/react-native-contacts#ios

Solution 2:

Follow the steps mentioned in the documentation of react-native-contacts, and add a catch block at the end, it worked for me.

PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
            {
              'title': 'Contacts',
              'message': 'This app would like to view your contacts.'
            }
          ).then(() => {
            con.getAll((err, contacts) => {
              if (err === 'denied'){
                // error
              } else {
                // contacts returned in Arrayconsole.log(contacts);
              }
            })
          })
          .catch((err)=> {
              console.log(err);
          })

Post a Comment for "React-native-contacts Getall Return Null"