Can any one please guide me ? Is it possible to open contact screen programmatically in iOS (swift)
Asked
Active
Viewed 5,311 times
4 Answers
16
Try this below code. I think I am getting what you are looking for.
let con = CNContact()
let vc = CNContactViewController(forNewContact: con)
_ = self.navigationController?.pushViewController(vc, animated: true)

Rishab
- 1,901
- 2
- 18
- 34
-
I think you just upvoted. :P Accept comes in green tick mark. – Rishab May 18 '17 at 11:36
-
Hi @Rishab can you help me for open contact detail page dynamically in swift https://stackoverflow.com/questions/61650767/open-contact-information-details-page-via-phone-number-in-ios-programatically – Urvashi kharecha May 15 '20 at 07:05
5
Its possible to open this screen directly with some pre populated fields. No need of any workarounds.
let contact = CNMutableContact()
let homePhone = CNLabeledValue(label: CNLabelHome, value: CNPhoneNumber(stringValue :"number goes here"))
contact.phoneNumbers = [homePhone]
contact.imageData = data // Set image data here
let vc = CNContactViewController(forNewContact: contact)
vc.delegate = self
let nav = UINavigationController(rootViewController: vc)
self.present(nav, animated: true, completion: nil)

Murali
- 1,869
- 1
- 14
- 22
-
I get the error in `vc.delegate = self ` and the last line where it says `Use of unresolved identifier 'self'` – Novak Nov 26 '18 at 14:19
1
Till iOS 10.3.1 there is no public api to open contacts screen directly to add new contact. You can use ContactsUI framework to open contacts within your application and then from that contact screen add new Contact.
For reference :-

Himanshu
- 2,832
- 4
- 23
- 51
-
Thanks, but is it possible to skip "Add new Contact" did select option and jump to above screen ? same like whatsapp – Bucket May 18 '17 at 11:18
-
You need to manually click on add button over the contacts to open this screen. – Himanshu May 18 '17 at 11:19
0
It is not possible to open new contact list but you can open contact list and select add new contact.

Ved Rauniyar
- 1,539
- 14
- 21
-
1How WhatsApp open contact list for adding new contact from shared contact ? – Bucket May 18 '17 at 11:15