I want to ask a question about iPhone. Is it possible to retrieve the creation time from the iPhone contacts of each record? Thank you.
For iOS6+ it's a bit different:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
/* -> I left out the ask for permission code here */
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, nil);
if (addressBook != nil)
{
NSArray *allPeople = (__bridge_transfer NSArray
*)ABAddressBookCopyArrayOfAllPeople(addressBook);
for( id contactPerson in allPeople )
{
NSString *firstName = (__bridge_transfer NSString
*)ABRecordCopyValue((__bridge ABRecordRef)(contactPerson), kABPersonFirstNameProperty);
NSDate* createDate = (__bridge_transfer NSDate*) ABRecordCopyValue((__bridge ABRecordRef)(contactPerson), kABPersonCreationDateProperty );
NSString* formattedDate = [dateFormatter stringFromDate:createDate];
NSLog( @"%@ created %@", firstName, formattedDate );
}
}
CFRelease(addressBook);