morenoh149 / react-native-contacts

React Native Contacts
MIT License
1.65k stars 564 forks source link

Feature Request: getContactsByPhoneNumber match regardless of underlying format #579

Closed the-dimensionless closed 3 years ago

the-dimensionless commented 3 years ago

If a = '1234567890' and contact is '123-456-7890', get contact by search string does not return the contact

morenoh149 commented 3 years ago

Please share your code, I don't know which method you are using. Also feel free to add this scenario to the example app to make sure we get it working.

the-dimensionless commented 3 years ago

getContactsByPhoneNumber(string) is the method used.

Say number in Phone is '074 350 2341', i calll getContactsByPhoneNumber('0743502341'), [] list is returned. Is there a way that we can match numbers after ignoring their formatting ?

morenoh149 commented 3 years ago

@the-dimensionless what you see in the readme is what you get. If you want a different api please propose it and submit a PR implementing it.

github-actions[bot] commented 3 years ago

This issue is stale, please provide more information about the status

vetrivendhan48 commented 3 years ago

Suggestion: The possible search method can be, getContactsByPhoneNumber('0743502341', true) or getContactsByPhoneNumber(mobileNumber', mobileNumber.length> 3) the expected change to the library is as follows // getContactsByPhoneNumber(mobileNumber: string, isSearchInNativeFormat: bool)

If modified our function in this way, then our function work as follows Step 1: Convert normal mobile number (0743502341) to formatted mobile number (123-456-7890). Step 2: Do a search query with the formatted mobile number (123-456-7890). Step 3: Return matched results.

Any more suggestions are appreciated, Thanks.