Is it possible to detect deleted Address Book entries (for example from the iOS phonebook itself) from within an application?
I have an application which needs to synchronize a local copy of the iOS Address Book database with the Address book from the phone. The application supports background mode on iOSes which support it.
Testing the application in a background capable iOS environment my problem is the following:
The application does not detect an entry which has been deleted in the system address book until the application is closed completely (iOS 4 killing it with the red X in springboard). If the application is simply sent to the background, a contact is deleted from the system address book, and then the app brought to the foreground again the function ABRecordRef() for the deleted entry id does not return NULL as would be expected for an entry which no longer exists, it returns the entry as if it had never been removed from the system address book database.
As above – if the application is completely terminated and restarted then ABRecordRef() for the deleted id works as expected – it returns NULL. Is there any way to detect this deleted entry without waiting for the app to be killed and restarted?
Yes. Register for changes to the address book with
ABAddressBookRegisterExternalChangeCallback, e.g.Where
MyAddressBookExternalChangeCallbackis your callback function.