0

I have implemented CNContactViewController to show phone number details controller.

let store = CNContactStore()
let contact = CNMutableContact()
let homePhone = CNLabeledValue(label: CNLabelHome, value: CNPhoneNumber(stringValue :phNo ))
contact.phoneNumbers = [homePhone]

let contactViewController.contactStore = CNContactViewController(forUnknownContact: contact)
contactViewController.contactStore = store
contactViewController.delegate = self
contactViewController.allowsActions = false
self.navigationController?.pushViewController(contactViewController, animated: true)

Contact details present logic working perfectly and when I click on message or call it called shouldPerformDefaultActionFor delegate method.

func contactViewController(_ viewController: CNContactViewController, shouldPerformDefaultActionFor property: CNContactProperty) -> Bool {
     // Is Message Button Tapped  
     // OR
     // Is Call Button Tapped

     return 
}

Above delegate return CNContactProperty which description is like below:

Printing description of property: <CNContactProperty: 0x293212e40: contact identifier=C0FE0EB0-DB4E-4CCD-9116-2035A0CEEAC7:ABPerson, contact name=Parth Patel, key=phoneNumbers, identifier=2F19012A-94E1-4D35-9E46-EFC913F1869F, value=<CNPhoneNumber: 0x28fc30bd0: stringValue=14084002399, initialCountryCode=(nil)>>

From that response I am not able to identify which action is get called. Is it Message or Is it Call or anything else.

Please help me. How to identify which action tapped.

Thanks in advance.

enter image description here

Parth Patel
  • 915
  • 11
  • 33
  • 1
    The contacts UI programming interface is pretty dreadful. You are correct that this information is not provided. If you think you have a use case, please file a bug with Apple asking for this programming interface to be improved. – matt Sep 06 '22 at 12:12

0 Answers0