Contact is missing some of the required key descriptors in ios

后端 未结 3 1204
被撕碎了的回忆
被撕碎了的回忆 2021-01-04 18:35

I have retrieves all contact by using following method

- (void)getAllContacts:(void(^)(NSArray *array))handler
{
    CNAuthorizationStatus status = [CNContac         


        
3条回答
  •  旧时难觅i
    2021-01-04 19:34

    You need to add [CNContactViewController descriptorForRequiredKeys] as an array of keysToFetch you have to pass in your CNContactFetchRequest.

    Example:

    CNContactFetchRequest *request = [[CNContactFetchRequest alloc] initWithKeysToFetch:@[CNContactIdentifierKey, CNContactEmailAddressesKey, CNContactBirthdayKey, CNContactImageDataKey, CNContactPhoneNumbersKey, [CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName], [CNContactViewController descriptorForRequiredKeys]]];
    

提交回复
热议问题