Recovering contact info of the current user - ios

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?

Related

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.

How whatsapp get updated contacts from addressbook faster in iOS?

My findings
I am designing a logic to sync contact with my Backend. I gone through some apps that doing same thing in IOS. I will take the example of WhatsApp, I found that When I update any contact in Native Addressbook, it reflect that change into Whatsapp withing a fraction.
My Concern
I just want to know that how it is syncing in a very faster way. Even a new contact gets synced with its Remote server and get displayed on contact, and with the ability to initiate Whatsapp chat if that number is registered one.
Summary of Queries
So, in nutshell my queries are,
How Whatsapp is syncing the contact?
How whatsapp is getting just updated contact list from Native Addressbook (if it's doing so) ?
How whatsapp is just getting just new Contact added in addressbook, is there anything that manages like timestamp or anything else?
I know the following things are there like,
ABAddressBookGetPersonCount
ABAddressBookGetPersonWithRecordID
ABAddressBookCopyArrayOfAllPeople
Using the ABAddressBookGetPersonCount i can know if any new contacts are there but still how i will be able to know its Record ID without iterating each contact using ABAddressBookCopyArrayOfAllPeople
So i am just asking for the way to get just updated list.
The way to do this is by registering an external change callback. This way, your app will be notified of any changes to the address book as soon as they happen.

Is it possible to programmatically disable an ABSource or ABGroup in the main Contacts app?

I'm building an alcohol prevention app and one of the features is to block the user's contacts for a given period of time so that they don't irresponsibly make drunken calls/texts to people.
The current (and very old) version implements it by letting the user select in-app which contacts to block. Then, it directly changes the selected contacts' phone numbers to an invalid one. That way, even if the user goes to the Phone or Messages app, the call or text won't be sent to the contact because the number is invalid.
I very strongly dislike this approach because it screws up with your address book which can be synced across multiple devices. What I have in mind is to:
Create a separate ABGroup or ABSource of contacts for my app
Copy all the contacts from other groups and sources into my app's group or source
Falsify all the contacts' phone numbers in my app's group or source
Disable all the other groups or source in the main Contacts app.
My question is: Is this possible? I looked into the ABSource and ABGroup references but can't find properties to disable them, but I'm hoping it's available somewhere in the SDK and that I'm just being blind.
If it's not possible, I'd be happy to hear any ideas for alternative implementations (iCloud backups, write original data into a file and screw up everything then put it back later, etc).

Populating user details from the contact list

I am working on an app and need to make the user enter information like name, phone, address etc. Inside my app is it possible to show the contact list (Address book) and make the user pick the contact he wants to use. I am specifically hoping to find a way that also give me the UI and search functionality within the contacts just like the regular contacts list. So when the user wants to enter the information, I show him the contacts list (with the same UI/functionality or a subset of it) and let him pick the contact. Is there a way to do this in iOS?
Address book is there. USe that .
This answer can help you.
Get a list of all contacts on iOS
Fetch Contacts in iOS 7
How to simply retrieve list of Contacts in iOS7?
If, you want a tutorial, here is the link Tutorial link

Find Favorite contacts from the iOS Address Book API

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.

Resources