In my app I am getting all address book data. But when I start app next time I just want to retrieve modified/newly added contacts in address book.
Can you please suggest me any possible ways?
Thanks.
From iOS 9 you can register your class to observ CNContactStoreDidChangeNotification:
Obj-C code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addressBookDidChange:) name:CNContactStoreDidChangeNotification object:nil];
And then:
-(void)addressBookDidChange:(NSNotification*)notification
{
//Handle event here...
}
Swift code:
NSNotificationCenter.defaultCenter().addObserver(
self,
selector: "addressBookDidChange:",
name: CNContactStoreDidChangeNotification,
object: nil)
And then:
@objc func addressBookDidChange(notification: NSNotification){
//Handle event here...
}
as reported in Contacts Framework Reference
After a save is successfully executed, the contact store posts a CNContactStoreDidChangeNotification notification to the default notification center. If you cache any Contacts framework objects you need to refetch those objects, either by their identifiers, or with the predicates that were used to originally fetch them, and then release the cached objects. Note that cached objects are stale, but not invalid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With