Rahul
Rahul

Reputation: 5844

How to add a Contact in Contact using iPhone Native UI

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.

Upvotes: 0

Views: 1540

Answers (1)

Midhun MP
Midhun MP

Reputation: 107231

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];

Upvotes: 7

Related Questions