How do apps like Path and Instagram tell if contacts are also using the app? - ios

I am interested in building an app that has a Find Friends by contacts function similar to Path's or Instagram's but am not sure how it's done.
I know Path and Instagram upload your address book to their server, but how are they able to tell if a particular contact is also using the app? Does it also upload the user's phone number and thus match by phone numbers?
CLARIFICATION: I do not save email addresses (or any info other than the contact's phone number) in my address book, yet somehow Path and Instagram are able to tell if that phone number belongs to a user on Path / Instagram. How is this?

There are two join points between your address book and theirs:
Your e-mail address (and phone number).
Your friends address books that contain your e-mail address (and phone number).
Basically, just because you don't have their e-mail address listed doesn't mean they don't have yours listed. They could also filter this "who has your e-mail in their address book" based on the names and/or phone numbers in your address book.
Yes, it could also be joining on phone number. The point here is that there are many ways to join data together, and your phone doesn't have the complete picture of what they have.

Related

Can CloudKit user phone numbers be retrieved using `CKDiscoverAllUserIdentitiesOperation`?

Background
I am retrieving all the users for my app using the recommended CloudKit operation, CKDiscoverAllUserIdentitiesOperation.
This operation is designed to returns each user's info in a CKUserIdentity object. The lookupInfo attribute of the user identity has fields that can contain the user's email address and the user's phone number.
e.g.
user.lookupInfo.phoneNumber
user.lookupInfo.emailAddress
Question
When I run this operation, I only ever get each user's email address. The phoneNumber field is never populated.
How do I retrieve these user identities and have them include the user's phone number? (Is this possible?)
Additional Info
I am able to retrieve individual users with their phone numbers using the discoverUserIdentity(withPhoneNumber... CloudKit function, so I know that these accounts are linked to phone numbers.
All you get is the email. That's it. It's not possible to get any more info than that using CKDiscoverAllUserIdentitiesOperation. And that is only for users that have agreed to be looked up via email while using your app.
The only time the phone number is filled in is if you specifically lookup the user by phone number. Of course that's kind of pointless since you already know the phone number.

Recovering contact info of the current user

I'm having trouble searching online for this and I've missed it in the reference materials if it's there.
I'm writing an iOS app in Swift, and there are participants in the app whose contact info can currently be saved into the user's address book, using the Contacts Framework.
What I'd like to do is when the user has to save their own participant information into the system, I'd like to present their default contact info from the address book as the text fields' default text. I figured this would be possible using the contacts framework, but I'm not sure how to fetch the current user's information.
Does the contacts framework even keep track of that? I thought it did, because the Contacts app has my own phone number at the top of it's listings, but I realized afterwards that it's just the device's number, not a whole contact file. If so, do I search for it with a specific predicate or is their a function I can call?

How does snapchat do their friends functionality?

So I am trying to have users in my app find each other via their address book (a la Snapchat). How do I go about this?
I can have access to the user's address book so I would be able to associate each number with a user (I verify this via text for each user). Once I have all these users associated though, would I have to compare each phone number to my data base (Parse) in order to have a section of "Friends who have MyApp"? Otherwise, how can I grab an address book of X user and tell them which of his contacts have the App already installed?
Also, I have read in many places I should not upload their contacts info to my backend.
Help?
First thing that comes to my mind is to store each user's phone number as well. However, you might be right about not to upload their contacts to your server even though you do ask for confirmation that you're going to access their contact list.
I'll put forward another idea, how about storing their contact list as encrypted data? Thus, even you personally won't be able to reach any of the contact info. Use an irreversible encryption algorithm like sha512 and then store these phone numbers as encrypted strings. Each time a user requests if his/her contacts are exist in your database, encrypt each phone number locally and make a request if those strings exist in your DB. This implementation is really similar to common password storing techniques and I believe it is quite secure -and ethical.
Related: How can I compute a SHA-2 (ideally SHA 256 or SHA 512) hash in iOS?

Matching phone numbers with certainty from address book

I am creating an app that allows users to find friends via address book contacts. Users have to enter their own phone number(including area code) when they sign up. Given an user A, I currently compare phone numbers in the database(phone numbers gathered from sign up) with user A's address book contacts. However, I noticed that some contacts on my phone do not have area codes. Is there a way to ascertain whether two numbers are the same when no area code is available?
I would suggest storing the area code and number separately. This way, you would be able to compare non area coded phone numbers with some degree of confidence, as opposed to just checking against the last 7 digits of a 10+ digit phone number.

Getting contacts who own an iDevice

Is there a way through addressbookUi framework to get only the contacts who own an iDevice? The check for example is done in the messages app for iMessage. But is this available for developers? Or is there another way to check for this? Thank you in advance..
You could check, for each address book record, if there is a phone number of type "iPhone" (represented by the constant kABPersonPhoneIPhoneLabel). There's really no way of knowing for sure which of the contacts "owns an iDevice" anyway, but if there is an iPhone number for them in the address book record, then there's a good chance of them using an iPhone. Of course, it's another story altogether how that information got in your address book, and whether it is reliable.
No there isn't... The SMS app would be checking with apples servers to see if the phone number is registered with iMessage or not.
This is not a publicly accessible API.
I guess you could hash then send the users number to your own remote database and then compare contact numbers in another users address book against your database to see if they are users of your app... It's not really what you asked to do but it's the closest solution I could think up

Resources