How to get creation date of contact Using AddressBook in iOS

581 Views Asked by At

I have to export iOS device contact data and filter using "contact creation date" .Is it possible to do using Objective C ?

1

There are 1 best solutions below

4
Avaan On

You can get creation date of any contact as below,

ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, err);
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
ABRecordRef person = CFArrayGetValueAtIndex( allPeople, 0 );

NSDate* createDate = (__bridge NSDate*) ABRecordCopyValue( person, kABPersonCreationDateProperty);
NSDate* updateDate = (__bridge NSDate*) ABRecordCopyValue( person, kABPersonModificationDateProperty);