4

I'm currently building an app in Swift and I'm having some trouble implementing a feature.

When a user signs up, he enters his phone number which is then stored in the database. Right after the sign up process, I want to display a list of all the user's contacts that already use the app so he can add them, but also the others, so he can invite them via SMS.

On my API, I have an endpoint that can return all the users that match in a list of phone numbers. Right now, I'm trying to do this :

  • get all the phone numbers in the Address Book
  • send them to the API to see if some of these numbers are matching with registered users
  • if there's a match, get the list of users back in the app
  • update my table view with the data, adding correct button (add or invite) in each cell

My problem is : I don't know how I should link that returned data from the api to my contact list knowing that each contact can have multiple phone numbers. Should I go through my contact list and for each contact, find if one of the phone numbers is contained in the array of users returned by the API ?

I find the process quite heavy. I need to get through the Address book one time to get the phone numbers and display the contacts names on the table view, and then another time to link the data provided by the API to the correct cells.

Is there a better way to handle this ? I'd like to hear your thoughts !

Simon
  • 127
  • 1
  • 8
  • http://stackoverflow.com/questions/24185780/ios-list-of-contacts-with-same-app-installed try this out – Lukesivi Dec 15 '15 at 13:56

0 Answers0