3

I can monitor contacts change using:

NotificationCenter.default.addObserver(
            self, selector: #selector(contactStoreDidChange), name: .CNContactStoreDidChange, object: nil)
    }

@objc func contactStoreDidChange(notification: NSNotification) {

}

But how can I get the changed contacts from the notification? Things like which contact is added/removed/changed etc?

jiawen
  • 1,198
  • 2
  • 17
  • 29

1 Answers1

2

You just can get notify in the method.and you have to then refetch all objects and create your dataSource again for updated data!!

Tanvi Jain
  • 917
  • 2
  • 7
  • 19
  • 2
    If I have more than 1000 contacts and if i try to re-fetch all my contacts is slowing down my app. how to solve this issue?? – Ramakrishna Apr 18 '17 at 13:13
  • 1
    You will have to perform this task in background without the attention of user, if you find some contacts updated then you can refresh UI , else its not even required, and user won't see any changes in performance. – vishal dharankar Jun 30 '17 at 04:21
  • I found this https://stackoverflow.com/questions/17440115/detect-what-was-changed-from-abaddressbookregisterexternalchangecallback – Umair Mohammad Apr 03 '18 at 09:25