my app registers the callback once
Code:
notificationAddressBook = ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(notificationAddressBook, MyAddressBookExternalChangeCallback, self);
then in my callback
Code:
void MyAddressBookExternalChangeCallback (ABAddressBookRef notifyAddressBook,CFDictionaryRef info,void *context)
{
NSLog(@"in MyAddressBook External Change Callback");
ABAddressBookRevert(notifyAddressBook);
CFArrayRef peopleRefs = ABAddressBookCopyArrayOfAllPeopleInSource(notifyAddressBook, kABSourceTypeLocal);
CFIndex count = CFArrayGetCount(peopleRefs);
NSMutableArray* people = [NSMutableArray arrayWithCapacity:count];
for (CFIndex i=0; i < count; i++) {
ABRecordRef ref = CFArrayGetValueAtIndex(peopleRefs, i);
ABRecordID id_ = ABRecordGetRecordID(ref);
TiContactsPerson* person = [[[TiContactsPerson alloc] _initWithPageContext:[context executionContext] recordId:id_ module:context] autorelease];
NSLog(@"name: %@", [person valueForKey:@"firstName"]);
NSLog(@"phone: %@", [person valueForKey:@"phone"]);
NSLog(@"modified: %@", [person valueForKey:@"modified"]);
[people addObject:person];
}
CFRelease(peopleRefs);
}
when adding a new contact the event is triggered fine, and the data is up-to-date in the first addition and the second and third... the problem is with editing an existing contact details.
the first time the event is triggered the data is true to the last update (I changed the phone number of one contact in the iphone address book), then I switch to the app and get the latest update. then I switch back to the address book make another change, switch to my app and get another event... this time the data is stale, the latest changes are not reflected.
I tried releasing the addressbook instance and run another ABAddressBookCreate() but it did not help either.
any ideas ?