Many SO questions were raised regarding listening to iOS address book change callback. Famous question Address book sync.
But my question is narrow, i.e. How can we get which contacts were deleted during addressbook sync callback.
void MyAddressBookExternalChangeCallback (ABAddressBookRef ntificationaddressbook,CFDictionaryRef info,void *context)
{
NSLog(@"Changed Detected......");
/*
NSDate *lastSyncTime = [self gettingLastSyncTime];
// By above time, I could get which contacts are modified(kABPersonModificationDateProperty)
// and which contacts are created newly( ABRecordGetRecordID()
// But how can I get this contact was DELETED?
*/
}
But somebody cleared this problem in Detect what was changed..... In this, they did (a) Storing all record ids in first time (b) During sync, check all stored record ids with current address book ids, to check if they are available or not. If not, then assume it to be deleted contact (costly operation).
My question: Is there any other way to detect DELETED contact?
As far as I know, the only way to do it is to store contact ids in some way and check modified, cause
MyAddressBookExternalChangeCallback
is only called when your app is active or in background, so when your app is terminated you would not be able to track those changes. Here is my implementation of address book sync controller which just keeps up to date your local contacts with devices: