How can I display contact image on Apple Watch

Viewed 45

I have built an application (in SwiftUI) which work with contacts and displays information about contacts including contact image. I use CNContact class (CNContactImageDataKey). It works fine on iPhone, but when I run the same code on Apple Watch, it returns nil. I will appreciate any help, how display contact image in Watch app. Thanks in advance.

My code:

let keyToFetch = [CNContactGivenNameKey, CNContactPhoneNumbersKey, CNContactImageDataKey, CNContactBirthdayKey, CNContactFamilyNameKey,CNContactIdentifierKey, CNContactEmailAddressesKey] as [CNKeyDescriptor]
let fetchRequest = CNContactFetchRequest(keysToFetch: keyToFetch)

try store.enumerateContacts(with: fetchRequest, usingBlock: {(contactInfo, _) in
    let image = contactInfo.imageData
0 Answers
Related