How to share contacts? - iphone

By using IPhone SDK (on a jail broken iPhone), how can I share a contact (.vcf file) through mail as same as the address book is doing?
Regards,
Prathap.

Have you looked at the Address Book Framework reference? It allows you to fetch records from the Address Book database. You may have to put this data in vCard format yourself, I don't know if the framework provides this functionality for you.

Yes, you can do this on the iPhone:
ABAddressBookRef addressBook = CFAutorelease(ABAddressBookCreate());
NSArray* contacts = (NSArray*)ABAddressBookCopyArrayOfAllPeople(addressBook);
Erica Sadun's ABContactHelper classes come in mighty handy if you want to mess around with the Address Book interface.

Related

Showing custom contacts like iphone Address book

I have tried
http://zcentric.com/2008/09/19/access-the-address-book/
And it works great. But now instead of AddressBook contact i have an array or other structure that have my contacts and i want to show it like an Address Book.
Do i need to make it all custom or is there any way i can use the AddressBook to show my contacts?
Using ABPeoplePickerNavigationController you can only fetch the contacts from the Ipad or Iphone Address Book.
If you want same functionality with your structure data you need to make it all Custom Using UITableView and other views.
read Addressbook Programming Guid here from apple and you will get detailed answer of your question.

ABAddressBook - multiple address books?

I am building an app which syncs contacts from an online source. Everything works fine so far...when the phone has one address book:
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef group1 = ABGroupCreate();
ABRecordSetValue(group1,kABGroupNameProperty,#"Group1",nil);
ABAddressBookAddRecord(addressBook,group1,nil);
ABAddressBookSave(addressBook,nil);
ABRecordRef person = ABPersonCreate();
// Edit person values...
ABGroupAddMember(group1,person,nil);
ABAddressBookAddRecord(addressBook,person,nil);
ABAddressBookSave(addressBook,nil);
CFRelease(person);
CFRelease(addressBook);
The problem occurs, however when the phone already has multiple address books. I am testing on a phone that has one address book for All Contacts, one for Gmail, etc. When I add a contact in the above manner, it adds it to the Gmail address book, and in the process strips the "Group1" identifier from the contact. Is there a way I can change the ABAddressBookRef to point to a specific address book within the phone?
According to the reference, ABAddressBookCreate always returns an address book object populated from the system's address book database. Which means there is only ever one address book, even if you have multiple instances of ABAddressBook that you use to interact with it.
Mike, you might want to take a look at this post:
Obtaining Specific ABSource from ABAddressBook in iOS 4+
Although I believe Alex is right that there is only ever one address book, that address book may consist of multiple sources (ABSource). And, in iOS 4+ it is possible to specifically identify and manipulate particular sources.

Getting list of contacts from phone book in Iphone application

I just want the all contacts list in my application, in NSArray or NSDictionary object or in any other form. My intense is that my application do also have its own contacts. Now I want to show my application's contact and native contacts in my application's phone book. So I just want the list of native contacts in some way so that I can show it along with my application's contact list. Thanks in advance........
Apple has a programming guide for the address book framework that should give all the information you need:
Address Book Programming Guide for iOS

How to add a contacts to contact book in own program?

I want to ask a question about the iPhone application. The application can let the user to enter the information in a costumed table (not the contacts book). After that, the program will use the retrieved data to add to the address book. But I don't how to add the content to contacts book. Can any one help me? Thank you very much.
The framework you are looking for is the AddressBook framework, and the guide within the SDK is called "Address Book Programming Guide for iPhone OS"
The method that does this is called ABAddressBookAddRecord

iPhone Address Book custom property

I am developing an application which is similar to native contact book app of iphone. I want to add additional property/field in native iphone address book database. e.g. network carrier of each contact (AT&T).
How to access the database of native address book from our app? Is that possible to do?
You cannot add custom fields. You can add data into the Notes field, but not add any custom fields into the AddressBook Person class. You can extend the AddressBook but you will need to save the data somewhere else and link the Person to the data you saved.
You can access the data from the address book using the AddressBook framework.
addPropertiesAndTypes is only available on Mac OS