Get Contacts out of Address Book who also use the application - ios

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

Related

How would I be able to uniquely identify a contact in a contact store in a iOS device?

I need someway to uniquely identify a contact in contact store even if the contact is changed.
Is there a way to put code in iOS that is always watching in the background for the contact store to change? That way I can track a contact that I identify with a UUID value and make sure I can always match that specific contact with its UUID value even if the contact changes. If I put it in my app, then the user can close the app, and the app won't receive notifications when the contact store changes? Is there an app extension I can use that would allow me to do this, whether that is the intent of the extension or not?
Perhaps I can use key-value observing. Is it possible to observe the iOS Contacts app or the contacts store of a device using key-value observing? How would I find out? I can't find information on it when I do a search on Google.
I found information about the ABAddressBookRegisterExternalChangeCallback(::_:) function of the Address Book Framework, but that function has been deprecated, and only works with iOS 2.0–9.0. I don't see a function in the Contacts Framework that does what that function does.
Content Added Thursday, March 3, 2022, 12:03 AM:
I need the unique identifier to be saved in a record in a private iCloud database. The objective is to be able to query the database for the record associated with that contact. That would probably mean that the identifier would have to be unique across all iOS devices in existence.Is that so?

CloudKit: can't discover identities

Pretty new to CloudKit. Trying to get all the contacts who are using my app. According to the docs and the tutorials out there I'm calling this:
discoverAllIdentities(completionHandler:)
The issue is that only my user (the one who is logged in on the device where the app is running) is returned. So I did some digging and noticed that if I call this one:
discoverUserIdentity(withPhoneNumber:completionHandler:)
and I use phone number directly the user is returned.
So after more investigation, I figured that the reason I do not get those users is that in my Contacts those users do not have their iCloud email stored. So once I add the email, they are returned by discoverAllIdentities(completionHandler:). So it appears the default implementation of that method is tied to iCloud emails for the discovery instead of phone number.
Is it possible to use phone number for discoverAllIdentities(completionHandler:)? Since, I don't think that as you add a new contact you would record anything but just phone number, so you will be missing to discover all those users.
Any kind of help is highly appreciated.

Unique MSConversation.localParticipantIdentifier in iOS simulator

When testing iMessage applications in the iOS simulator, retrieving the MSConversation.localParticipantIdentifier in the two default conversation threads (Kate Bell, John Appleseed) returns the same NSUUID string because we are still on the "same device".
To implement a turn based app, I am passing the localParticipantIdentifier with the URL data to keep track of the participants' turns.
Person 1 would pass his ID in the message to Person
Person 2 would compare passed ID to her own to determine if she made the last turn.
Is there a way to simulate a unique localParticipantIdentifier between the two test conversations on the iOS 10 simulator? Besides hardcoding the "turn" info for debugging, I cannot think of a way to simulate this real world condition. Thanks.
Note: I do not want to use MSMessage.senderparticipantidentifier because the sender does not necessarily determine who made the turn (ex: user sends a message that updates the app state but is NOT a "turn", 3+ person conversation thread, etc).
Personally I would use remoteParticipantsIdentifier from MSConversation.
So the idea is to keep a reference of the latest move with the id of who did the move, and allow the user to play if its id matches with the list of remoteParticipants (and if he is the next on that list).

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()?)

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