I'm developing app with using of native address book. I've registered a callback to receive a notification when address book has changed externally.
ABAddressBookRegisterExternalChangeCallback(myAddrrbook, changefunction, self)
My app can make new records inside AddressBook
, to do it I'm using ABNewPersonViewController
like that:
ABNewPersonViewController *controller = [[ABNewPersonViewController alloc] init];
controller.addressBook = myAddrrbook;
The problem is, that I still receiving notificat开发者_运维技巧ions when I using my own app like it changed somewhere else.
But when I run on the simulator, everything is OK
and no notification sent when I adding a contact.
How to avoid receiving notification on device?
Does anybody had face such problem?
The callback will be called whenever ANY app (including yours) modifies the device AddressBook. According to the Apple docs:
ABAddressBookRegisterExternalChangeCallback
Registers a callback to receive notifications when the Address Book database is modified.
(Found on the apple developer site)
In this case, the word "External" in the callback is probably best thought of as "external to the device's own address book handling code", not "external to my app"
As far as I know, the only way to filter out changes your app makes would be to set a flag before making any changes locally, and then check the flag in the callback (although that has potential for race conditions, it shouldn't be a major issue on an iPhone in most use cases)
精彩评论