I am developing an iOS chat application using Swift 3. When the app is launched for the first time it fetches all contact numbers from device using new Contacts API and sends those numbers to a server. The server returns a subarray of those numbers which are users of the app. Now how can I save those numbers?
1) Should I add them to application only memory (like sqlite DB)?
2) Should I add them again (as those numbers already exist in device contacts) to Contacts?
3) Should I modify the existing contact (like WhatsApp does)?
During my research and reading documentation I read about two things for CNContact:
a) CNInstantMessageAddress
b) CNSocialProfile
Now I updated the contact and CNInstantMessageAddress using this method.
let buzz = CNLabeledValue(label: "Buzz", value: CNInstantMessageAddress(username: "Buzz", service: "Buzz"))
This adds a new field in that particular contact but it does not open my App if tapped like WhatsApp does. So I think I am missing some part or maybe on the wrong track.
I have searched for how to create custom CNInstantMessageAddress
and not use the predefined services like CNInstantMessageServiceSkype
or CNInstantMessageServiceYahoo
but I cannot find a single example or even any documentation about how to add custom CNInstantMessageAddress
.
Any code example, link or any discussion would be helpful and will be appreciated. If I am doing this completely wrong, please guide me.