I am working on a iOS
Application in which I have to add
contacts in Address Book
.
I want to open Edit
Contact Screen Whenever user Tries to add duplicate
contact.
But I don't know how to do that.Currently I am only able to show a message only.
I am getting all contacts list as:
NSArray *allContacts = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBookRef);
Then I am itterating through it and check for existing one.If it exists then I am showing a message else I will add it to the addressbook.
for (id record in allContacts){
ABRecordRef thisContact = (__bridge ABRecordRef)record;
if (CFStringCompare(ABRecordCopyCompositeName(thisContact),
ABRecordCopyCompositeName(pet), 0) == kCFCompareEqualTo){
//The contact already exists!
NSLog(@"contact exosts");
}
else
{
ABAddressBookAddRecord(addressBookRef, pet, nil);
ABAddressBookSave(addressBookRef, nil);
ABMultiValueAddValueAndLabel(phoneNumbers, (__bridge CFStringRef)petPhoneNumber, kABPersonPhoneMainLabel, NULL);
NSLog(@"contacts Added");
}
}
How can I open following screen when user Tries to add duplicate contact:
I searched SO and find following questions but this doesn't help me. Question 1 Question 2
And Is it possible to do so or not.Please any one assist me to achieve this feature if it is feasible.