Presenting ContactUI CNContactViewController results in a privacy error and a CNUI error

450 Views Asked by At

I tried to programmatically present a CNContactViewController for a new contact, but I got error "Access to PassKit Shared Cache file denied. Please verify sandbox exceptions and/or file a Radar." The CNContactViewController also did not present.

I check that I had all valid permissions, such as Privacy--Contacts in the info.plist and that I had gotten the permissions in my code. I had.

let cnContactViewController=CNContactViewController(forNewContact: contact)
vc.present(cnContactViewController, animated: true)

I expected the app to present ContactsUI's CNContactViewController with a contact filled in it's fields, but it didn't happen, and I got two error messages: Access to PassKit Shared Cache file denied. Please verify sandbox exceptions and/or file a Radar. and CNUI ERROR Contact view delayed appearance timed out

2

There are 2 best solutions below

2
On BEST ANSWER

It turns out the first error, "Access to PassKit Shared Cache file denied. Please verify sandbox exceptions and/or file a Radar", didn't have to do with the CNContactViewController not presenting. To solve the problem of it not presenting, I used @Andrew Vyazovoy's post CNUI ERROR Contact view delayed appearance timed out and put the CNContactViewController as the root view controller of a navigation controller and presented the navigation controller, and the CNContactViewController showed on the screen. The privacy problem is unrelated.

1
On

I am getting same error, and i fixed by using below code

let vc = CNContactViewController(forNewContact: contact)
vc.delegate = self
let navigationController: UINavigationController = UINavigationController(rootViewController: vc)
            present(navigationController, animated: false) {
                print("Present")
            }