Matching phone numbers with certainty from address book - ios

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.

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.

How to get a country code from the given phone number

I have two phone numbers +17896786788 and +322657579849. I would like to retrieve only the code I.e, +1 and +322 by passing these phone number.
Is there any API avalable to get the code out of phone number?
libphonenumber gives the country code for the given country. Link: libphonenumber ios get country code for country
But I would like to get the code out of phone number.
I spent a long time investigating this, and so far there is no way to do this on iOS.
Sure we can make a guess, and it would work in most cases, but there is always some cases where it will be difficult, let me give you a few exemples:
Canada and USA share the same international prefix: +1
Martinique is part of France, but has its own international prefix: +596
Taiwan can be considered part of China or not depending on the user's interpretation
And the list goes on..

Making a faux iPhone dialer

I want to make a joke application for a friend (not for general sale) that looks exactly like the iOS Phone application but so that whatever number is dialled into the application it appears to dial that number but actually dials a preset number in the background.
The way I figured to do it would be through the following:
User enters a number and hits the call button
Save the number entered as a contact's name and programmatically set the number of that contact as the preset number
Get the application to ring the preset number, to which it would switch over to the real iOS phone application and dial, but with it being a saved number in the contacts it will display the name, which is the number entered by the user.
Delete that contact upon re-opening the application as for it to not ask which number to dial the next time.
This is the only way that I can think of pulling this off, but it seems like it will look unconvincing; especially when it switches over to the real Phone application. Can anyone think of a better way? Such as calling from within the application?
I wouldn't usually take junk requests like this but it made me curious as to pull it off best.Thanks
If you are not going to publish this, then there is no reason why you shouldn't use private apis. See this answer (How to directly make a phone call with private API CTCallDial()?)

Get Contacts out of Address Book who also use the application

I'm developing my first iPhone-application in Xcode and I was wondering if it is possible to get the contacts out of the Address Book of the iPhone who also use the application?
So what I need is a way to generate a unique ID based on the information in the Address Book, so that the ID that will be constructed for the same person will be the same on every iPhone where the application is used.
This way, I can use this ID as a primary key in the database I use to hold data that needs to be shared among users.
If I can construct this idea, I can also compute the ID for every Address Book member and check them against the ID's in my database to see who uses the app. But how can I construct such a unique ID?
I am not sure.. accessing phone number in iPhone allowed or not ... as far as I know its not possible .. but in your application you can ask user to enter the his mobile number and then you can make phone number as unique ID... whatsapp is using the same thing ...
For getting phone number check this ..
How can I get the phone number of my iPhone device?
Programmatically get own phone number in iOS
How to get the phone number programatically

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

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.

Resources