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

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.

Related

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

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

iOS : Get favorite contacts list in Contacts Framework [duplicate]

Is there a way to find Favorite contacts from the iOS Address Book API? I'm referring to the contacts a user places in his Favorites tab in the Contacts app.
Favorites are stored inside Phone.app, not inside the Address Book database itself. You can't access other app's sandbox on a non-jailbroken iPhone, so unfortunately the answer is no.
Also, it would be pretty bad for privacy if any app could see your favorite contacts. It's already bad that it can access entire address book without asking you.
Filip is correct, you cannot access the list of favorite contacts on iOS via a public, app-store legal API.
To come close you could try to guess a user's favorite or most important contacts from their address book. Let's assume that people know most about the people they are closest to and that this is also reflected by their phone's address book:
For example, the address book contact for a close friend contains more
information (address, birthday, maybe a nickname) than a contact for a
business associate or a colleague at work.
We could then use this information to compute an importance score for each address book contact. By taking the n most important contacts we could approximate a user's favorite contacts.
I've written about this idea some more on my blog: http://dbader.org/blog/guessing-favorite-contacts-ios You can also find a sample implementation and a demo application there.
I have searched through the API and could not find any appropriate methods. Maybe Apple believes that this is a Phone-app data field or maybe it is about security. I'd love to use it, too.

iOS: How Do I Make a Button To Allow Users To Tell a Friend About My App? [duplicate]

This question already has an answer here:
"Tell Friend" example which allow selection multiple contact
(1 answer)
Closed 8 years ago.
After searching Google for my question, all I could find was Ad-hoc distribution options and tutorials, and it seems the results are over saturated for questions such as mine.
I simply need to make a method in my program that brings up the typical share options (action sheet) to allow my user to select ALL/ANY of the available options to inform his or her contacts about downloading my app, via any means of which the iOS divide is capable.
I'm hoping this can be handled by the iOS since I don't yet know the URL to the App Store to download my app.
EDIT: I'm a bit annoyed with the fact that so many people have rushed to mark this as a duplicate when in fact it is not.
The link to the pre existing question is that of an EMAIL ONLY share option.
As above, i clearly state: "I simply need to make a method in my program that brings up the typical share options to allow my user to select all the available options to inform his or her contacts about downloading my app."
EMAIL IS NOT ALL THE OPTIONS THAT ARE AVAILABLE...!
To use the inbuilt API for the share options like the image below, you will have to import the Social Framework.
Check out the following SO questions:
Question 1
Question 2
Apple Documentation
To address the last part of your question: You can know the URL to your App Store page even before it's in stores.
As soon as you create the app in iTunes Connect, your app is associated with a link that can be found by right-clicking on the "View in App Store" button within your app's iTunes Connect information. When creating your "share options," this is the link you should share in order to link to your page in the app store.
As far as programming the actual sharing goes, you'll need to be more specific about the type of sharing you want to do. If you want to share via Facebook or Twitter for example you'll need to use the relevant SDK/API to do so; if you want to share via email, you can use MFMailComposeViewController or perhaps an SMTP client; if you want to share via SMS, you can use MFMessageComposeViewController or an SMS service like Twilio... all depends...
Edit: Someone just now down-voted this answer, probably just because there was no mention of the action sheet; but the initial question had no mention of an action sheet until 5 days after its post. Like aksh1t said, yes, you can use the Social framework in that case.

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

Is there a way to access the user's own address book data (first & last name, e-mail) in iOS?

I want to prefill some input fields in an app's registration process in order to make it more seamless. Is there a (Apple authorized) way to access this data?
Thanks,
Georg
No, what you want to do is an often requested feature, but for reasons unknown (probably security related) there is no way to even determine if the phone's owner has an address book entry. I suggest you go to bugreporter.apple.com and ask for this feature (as many of us already have!)
I think you need to pre fill the values from your device's address books. If so you have to dig your head into AddressBook Framework in order to access the contact details. Below link is from iOS developer link
http://developer.apple.com/library/ios/#documentation/AddressBookUI/Reference/AddressBookUI_Framework/_index.html
http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/AddressBook_iPhoneOS_Framework/_index.html#//apple_ref/doc/uid/TP40007212

Resources