How can I determine that CNContact is is favorites? [duplicate]

主宰稳场 提交于 2019-12-24 07:24:02

问题


My iOS application fetches contacts from device using code

[[CNContactStore new] requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError *error) {
  if (granted) {
    NSArray *keys = @[CNContactNamePrefixKey,
                      CNContactGivenNameKey,
                      CNContactMiddleNameKey,
                      CNContactFamilyNameKey,
                      // ...
    NSString *containerId = store.defaultContainerIdentifier;
    NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId];
    NSArray *cnContacts = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error];
    for (CNContact *contact in cnContacts) {
      // contacts fetching
    }
  }
}];

Has CNContact class some value means that contact is in favorites on device (in Phone application)? I didn't found such key in CNContact keys.

Or maybe predicate contains keys that I needs?


回答1:


Filip Radelic answered same question:

Favorites are stored inside Phone.app, not inside the Address Book database itself. You can't access other app's sandbox on a non-jailbroken iPhone, so unfortunately the answer is no.

Also, it would be pretty bad for privacy if any app could see your favorite contacts. It's already bad that it can access entire address book without asking you.



来源:https://stackoverflow.com/questions/39444444/how-can-i-determine-that-cncontact-is-is-favorites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!