Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syncing ABAddressbook-Entries

I have an iPad-appliction that syncs contact with the contacts on server side.

How do I detect only that ABAdressbook-Entries that have changed? It is possible, that there occur changes on server-side, in my application, or externally on the ipad.

When I use

void ABAddressBookRegisterExternalChangeCallback (
   ABAddressBookRef addressBook,
   ABExternalChangeCallback callback,
   void *context
);

I get the callback of external changes, but without any information about what changed. How do I get that information?

When I use the NSString * const kABModificationDateProperty I don't know what to compare with.

like image 526
James Avatar asked Apr 14 '11 07:04

James


2 Answers

I don't know, if you have got an solution for that. If not, probably this will help you:

NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(yourAddressBook);

for (int i = 0; i < allPeople.count; i++) {
    ABRecordRef *person = (ABAddressBookRef *)[allPeople abjectAtIndex:i];

    NSDate *lastModiDate = (NSDate*)ABRecordCopyValue(person, kABPersonModificationDateProperty);
    NSLog(@"Last modification date: %@ of entry: %@", lastModiDate, person);
}
like image 200
Mr. T Avatar answered Oct 21 '22 05:10

Mr. T


You'll need to actually compare all of the fields between the server and the local book for each person that you want to sync.

like image 45
Tony Li Avatar answered Oct 21 '22 03:10

Tony Li