How to find my own contact on iOS programmatically? [duplicate] - ios

Am I correct that with a address book permission we should be able to pretty reliably get a users phone number if they have given address book permissions via the new "My Card" contact that seems to be automatically added to your addressbook when you download IOS9?
I always wanted to do a find friends but i did not want to force users to type/verify their number....this seems to be a solid work around for ios9 users.

I am currently dealing with the same issue but unfortunately it seems that this is not possible according to Apple.
"Presuming that you’re working on iOS, there’s no programmatic way to identify the ‘me’ card. If you need to know, ask the user."
source: https://forums.developer.apple.com/thread/37564

Related

Is there a way to extract user’s full name from HealthKit in Swift?

I am trying to build a fitness app and I would like to build the user’s profile within the app but I would like to make it as quick and easy as possible for the user. I am able to extract the users stats such as height, body mass, birth date etc from HealthKit but is there a way for me to extract the user’s full name since the ios health app has this on it’s profile page.
I have sifted through the documentation, but so far I haven’t found anything.
no there is no api AFAIC.
you can ask for addressbook access and read the 'me' contact
Well you could go through all the contacts in the AddressBook and see if any of them are marked with the owner flag.
Just be aware that doing this will popup the "this app wants access to the address book" message. Also Apple isn't very keen on these kind of things. In the app review guide it is specified that an app can not use personal information without the user's permission.
You will get the username like this:
var username = NSUserName()!
and you can use same user name for your app.
Yeah, I don’t want to meddle with the address book and freak the user out. I’ll probably just ask them to enter their name instead.

Is the newly added 'My Card' that automatically shows up in IOS9 a reliable way to get a users phone number?

Am I correct that with a address book permission we should be able to pretty reliably get a users phone number if they have given address book permissions via the new "My Card" contact that seems to be automatically added to your addressbook when you download IOS9?
I always wanted to do a find friends but i did not want to force users to type/verify their number....this seems to be a solid work around for ios9 users.
I am currently dealing with the same issue but unfortunately it seems that this is not possible according to Apple.
"Presuming that you’re working on iOS, there’s no programmatic way to identify the ‘me’ card. If you need to know, ask the user."
source: https://forums.developer.apple.com/thread/37564

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

iOS access phone settings programmatically

is it possible to access the phone settings of an iOS Device programmatically? I'm currently building an app and there I will provide contact possibillities, for example a direct link for calling (you just push it and then the specific contact number is called).
But I only want to show that possibility, if the user isn't calling with an unknown number.
You can access the contacts stored in the phone using the Address Book framework. If you're unfamiliar with the framework, I suggest you take a look at this quick start tutorial.
EDIT It seems you wish to read the state of the Show My Caller ID system setting, however you cannot programmatically access the system settings.
Use ABAddressBook for getting contact details in your project...
see this

Use ABAddressBook to get the iPhone user in iOS [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How does Square's CardCase App Do This?
Is this forbidden? Square's iPhone App CardCase seems to be doing this when you create an account. It prefills fields with your email address, photo, and name from the iPhone's address book.
If not forbidden, how does one accomplish it?
Edit: I suspect they are doing this:
Programmatically get own phone number in iOS
and then looking for the phone number in the address book.
Getting Address Book information is not prohibited, in fact, there is a framework dedicated to the Address Book. See ABAddressBook Class Reference. Also, there are a ton of examples on the net that demonstrate how to access the address book, getting entries as well as adding entries.
There are several questionable methods for obtaining the current user's name or email which you could then use to look up their full contact details. However, these run you the risk of getting rejected by Apple. Instead, I would recommend asking for something simple (like phone number) to start off with and using that entered information to try to helpfully autofill the rest. Or assuming you are creating accounts for the user you could use Facebook, Twitter, Google and/or some other 3rd party authentication system instead of requiring all of their details again for your specific app.

Resources