I try to get a notification in my application whenever there is any change in the contact list of my iphone device. Here is the code I wrote to register the notifier:
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("contactChanged:"), name: CNContactStoreDidChangeNotification, object: nil)
func contactChanged(notification : NSNotification){
print("contact changed notification received")
var userInfo: NSDictionary!
userInfo = notification.userInfo
print(userInfo.allKeys.debugDescription)
}
My "contactChanged" method is called twice or thrice when the application returns from the background and if the address book has been changed. Also there is no information about what changes in the address book. Can you suggest how to make a notification only once? and find out about the changes? Thanks
source
share