I am creating a chat app, for which I need to check each of my contact list members if they are registered with my app and show the registered members list in my app.
Currently I am calling an API to check every number one by one. In case of 800 contacts it is getting called 800 times. I know this is not best way to do it. So, can some one please help me out and suggest me to do it in better way?

Below is my code:

```
 func createContactNumbersArray() {
    for i in 0...self.objects.count-1 {
        let contact:CNContact! = self.objects[i]
        if contact.phoneNumbers.count > 0 {
            for j in 0...contact.phoneNumbers.count-1 {
                print((contact.phoneNumbers[j].value).value(forKey: "digits")!)
                let tappedContactMobileNumber = (contact.phoneNumbers[j].value).value(forKey: "digits")
                let phoneNo = self.separateISDCodeMobileNo(mobileNo:tappedContactMobileNumber as! String)
                contactNumbersArray.append(phoneNo.1)
            }
        }
    }
    callGetAppUserDetailService(mobileNumber: self.contactNumbersArray[currentIndex] as! String)
}

```

I am doing this whole process in the background and refreshing the member list on front in current scenario.
I want to make the whole process as fast as Whatsapp.
['https://Stackoverflow.com/questions/52327462', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7257122/']
There is no way to do it without back-end modifications. So you need to work closely with your back-end engineer and build an API for this. 

Here is an advise how you can build this API:

To have 2 APIs: 

1) Upload the whole user address book to the back-end in a single request, something like:

```
let addressBook = NSMutableOrderedSet()

let contact1 = AddressBookContact()
contact1.name = "Jony Ive"
contact1.phone = "1-800-300-2000"
addressBook.add(contact1)

let contact2 = AddressBookContact()
contact2.name = "Steve Why"
contact2.phone = "412739123123"
addressBook.add(contact2)

let deviceUDID = nil

Request.uploadAddressBook(withUdid: deviceUDID, addressBook: addressBook, force: false, successBlock: { (updates) in

}) { (error) in

}

```

2) As a next step - retrieve a list of already registered users with phones from your address book, something like this:

```
let deviceUDID = nil

Request.registeredUsersFromAddressBook(withUdid: nil, successBlock: { (users) in

}) { (error) in

}

```

so now you can show it in UI

Found this example here <https://developers.connectycube.com/ios/address-book>
In fact,you can do little on client.
The normal way is: Server provide an interface that support check a phonenumber array, and return the phonenumbers has registered on server.