React-native-contacts: getContactsMatchingString returns empty array (iOS)

Created on 19 Apr 2019  路  7Comments  路  Source: morenoh149/react-native-contacts

Running getContactsMatchingString returns an empty array on iOS (works on Android) but getAll works fine. Any ideas?

export const getPhonebook = (dispatch, id) => {
  return dispatch => {
    dispatch({ type: "GET_PHONEBOOK_REQUEST" });
    Contacts.getContactsMatchingString("", (err, phoneBook, id) => {
      if (err) {
        console.log(err);
      } else {
        dispatch({
          type: "GET_PHONEBOOK_SUCCESS",
          payload: phoneBook
        });
      }
    });
  };
};

Most helpful comment

Just for others that might walk into the same issue. I also got an empty contacts array returned for iOS13 devices but I was on the older version 4.0.0 that didn't support iOS13. Updated to react-native-contacts 5.0.4 and everything is working again.

All 7 comments

is there a contact matching that string?
is it broken on both platforms?

@morenoh149 thanks for the response. There are about 1200 contacts on the test devices. getAll returns those contacts on both iOS and Android but getContactsMatchingString returns 0 contacts on iOS. The empty string should return all the contacts right?

I don't think so.

I got the idea from this issue about the getAll function in #327. iOS and android are currently not treating the filter the same then i.e. android returns all contacts if the string is "" while iOS returns none.

ok, we can change this issue into a bug tracking the discrepancy in behavior. If you could narrow this down and reproduce in the test app I'd really appreciate it! https://github.com/morenoh149/react-native-contacts-test

Just for others that might walk into the same issue. I also got an empty contacts array returned for iOS13 devices but I was on the older version 4.0.0 that didn't support iOS13. Updated to react-native-contacts 5.0.4 and everything is working again.

lets close this then. If anyone runs into a similar issue please open a PR with the relevant runtime versions listed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prathd picture prathd  路  5Comments

farrukhhashmi65 picture farrukhhashmi65  路  7Comments

luism3861 picture luism3861  路  9Comments

gulshanzealous picture gulshanzealous  路  3Comments

dubbelnisse picture dubbelnisse  路  10Comments