问题
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