0

I Want to add phone numbers in Contact List whenever user taps on a Phone Number.

I don't want to do it programatically in background and after saving just inform user.

I have recently seen Feature in trueCaller. In which When I click save to contact button then iPhone's default Contact add Screen is opened with Clicked Phone Number. I Searched SO and Web but found only adding via code.

How can I achieve this please assist me.

Rahul
  • 5,594
  • 7
  • 38
  • 92

1 Answers1

7

Below iOS 9:

You can achieve that by using ABNewPersonViewController available in the Addressbook Framework:

ABNewPersonViewController *addContactVC = [[ABNewPersonViewController alloc] init];
addContactVC.newPersonViewDelegate      = self;
UINavigationController *navController   = [[UINavigationController alloc] initWithRootViewController:addContactVC];
[self presentModalViewController:navController animated:YES];

iOS 9 or greater:

You can use CNContactViewController of ContactsUI Framework

CNContactViewController *addContactVC = [CNContactViewController viewControllerForNewContact:contact];
addContactVC.delegate                 = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addContactVC];
[self presentViewController:navController animated:NO completion:nil];
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • @midhumMP thanx it works... What if I want to display a contact by default..Suppose my numbers is 911-099099 when user clicks on it..in Add contact Screen It will show by default – Rahul Nov 24 '15 at 07:24
  • @RahulMishra: In ABNewPerson set the `displayedPerson` property for that. And in CNContactViewController, use the `contact` property for that. Set those properties with the values that you need to populate – Midhun MP Nov 24 '15 at 07:37