I am trying to add a new contact from my app with a profile picture, that contact number is already present in my mobile phonebook with other profile picture. CNContactViewController does not show the image that I formed in CNMutableContact.
It only shows the image present in the phonebook contact and not able to change profile picture in CNContactViewController forNewContact, When contact is already present in phone contacts.
Creating New Contact:
let filledContactObject = CNMutableContact()
filledContactObject.givenName = "John"
filledContactObject.phoneNumbers = [CNLabeledValue(label: CNLabelHome, value: CNPhoneNumber(stringValue: "4453527193"))]
if let imageData = UIImagePNGRepresentation(image) {
filledContactObject.imageData = imageData
}
Presenting CNContactViewController:
let contactVC = CNContactViewController(forNewContact: filledContactObject)
delegate = self
let navigation = UINavigationController(rootViewController: contactVC)
self.present(navigation, animated: true, completion: nil)