I am currently creating an application in Swift, and I am having problems implementing the function.
When a user signs up, he enters his phone number, which is then stored in the database. Immediately after the registration process, I want to display a list of all user contacts that already use the application so that it can add them, as well as others, so it can invite them via SMS.
In my API, I have an endpoint that can return all users that match the list of phone numbers. Right now, I'm trying to do this:
- get all phone numbers in the address book
- send them to the API to see if some of these numbers correspond to registered users.
- if there is a match, get a list of users in the application
- refresh my view of the data table by adding the right button (add or invite) in each cell
My problem: I do not know how to link the received data from the api to my contact list, knowing that each contact can have several phone numbers. Should I look through the contact list and for each contact, find out if one of the phone numbers is contained in the array of users returned by the API?
I find the process quite difficult. I need to go through the address book once to get the phone numbers and display the contact names in the table view, and then again associate the data provided by the API with the correct cells.
Is there a better way to handle this? I would love to hear your thoughts!