Address Book callback not called

Posted by Oliver on Stack Overflow See other posts from Stack Overflow or by Oliver
Published on 2010-04-24T23:59:30Z Indexed on 2010/04/25 0:03 UTC
Read the original article Hit count: 370

I have an iPhone app that makes use of the AddressBook.framework and uses Core Data to store these contacts. In order to make sure I update my own database when the Address Book is updated (whether via MobileMe or editing within my own app), I am subscribing to the notification as to when the Address Book is updating. I call this on startup:

ABAddressBookRef book = ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(book, addressBookChanged, self);

Which (supposedly) calls this on any editing. I have an ABPersonViewController which allows editing, and addressBookChanged never seems to get called.

void addressBookChanged(ABAddressBookRef reference, CFDictionaryRef dictionary, void *context) {
    // The contacts controller we need to call
    ContactsController *contacts = (ContactsController *)context;

    // Sync with the Address Book
    [contacts synchronizeWithAddressBook:reference];
}

Is there any reason for it to not be called?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core-data