Mayur Kataria Mayur Kataria - 6 months ago 46
Swift Question

How to get notified in contact changed event in IOS?

I wants to get notified when there is insert/update event to contacts of iPhone.

Is it possible to get notification to my app regarding specific contact changed event happened ?

Just a newbie... for IOS Swift.

I am not expecting full source code. Just wants to know whether its possible or not and also hint.

Thanks in advance.

Answer

In iOS it could be done using -

Register the external change call back notifier-

ABAddressBookRef ntificationaddressbook = ABAddressBookCreate();
    ABAddressBookRegisterExternalChangeCallback(ntificationaddressbook, MyAddressBookExternalChangeCallback, self);

Implement the call back -

void MyAddressBookExternalChangeCallback (ABAddressBookRef ntificationaddressbook,CFDictionaryRef info,void *context)
{
    // called when there is any change in AddressBook
}

For more details you can refer this link-

Detect what was changed from ABAddressBookRegisterExternalChangeCallback