Accessing contacts unbearably slow


#1

I’m building a social media app, and I want to implement a feature where users allow access to their contacts so that they can easily see who of their contacts has already registered with our app. For obvious reasons, I can’t really display a list of contacts that isn’t sorted both alphabetically and by contacts that already have an account.

When I test fetching contacts on my personal device (iphone X, 440 contacts) it takes almost 30 seconds to fetch them all, and that kind of speed isn’t tolerable.

I can’t sort the contacts alphabetically until ALL of the users contacts have been returned, and it’s only until after some of the contacts are returned that I can send a request to my app’s server that determines if a user with the phone number exists.

Even the shoddiest of internet connections returns requests from our server 30x faster than the contacts API returns contacts, so what do you recommend I do to handle how long the contacts API takes? I want the user to enable access to contacts during the onboarding process but I can’t have the user waiting 30 seconds or more to see if their friends have an account. Is there any way besides detaching my app to not rely on expo’s contacts API?


#2

Hey @prodigynelson,

How are you implementing the Contacts API in code? A good practice is to have them paginated and load more as the user scrolls through the list of contacts rather than loading the entire list at once when the user will only see a small portion depending on their screen size.

Cheers,

Adam


#3

I’m pulling 20 at a time, but the issue is that they need to be sorted alphabetically and continually sorting the unsorted data that the contacts API returns is inefficient. Additionally I’d really like to display them all at once instead of updating the sorted list as more come through. Is continually sorting them and displaying more as they come in really my best option besides detaching?


closed #4

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.