Syncing ABAddressbook-Entries
Asked Answered
C

2

10

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.

Cranky answered 14/4, 2011 at 7:39 Comment(0)
L
4

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);
}
Lyell answered 24/5, 2012 at 9:59 Comment(1)
Thanks for this. Not sure it makes a big difference, but I'd probably do this instead: NSDate *lastModiDate = (NSDate*) [person valueForProperty:kABModificationDateProperty];Guimpe
B
1

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.

Beria answered 7/6, 2012 at 15:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.