0

I'm currently working on an app, which take the all the address book contacts information and store it core data / Realm. But it happen only once, but how to capture when user add new contact / delete / update on the phone contact list.

Mudith Chathuranga Silva
  • 7,253
  • 2
  • 50
  • 58

1 Answers1

0

when user add or update the phonebook, you can capture the changes through external call back methods mentioned below.

IOS9

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(CNcontactDidChange:)name:CNContactStoreDidChangeNotification object:nil];

IOS8

 ABAddressBookRegisterExternalChangeCallback(book,MyAddressBookExternalChangeCallback,(__bridge void *)(self));

Then use the method mentioned below to update Realm ,

+ (instancetype)createOrUpdateInRealm:(RLMRealm *)realm withValue:(id)value;
Vijay Karthik
  • 457
  • 4
  • 6