我怎样才能确定CNContact是最受欢迎的? [重复]

时间:2022-09-07 11:03:49

This question already has an answer here:

这个问题在这里已有答案:

My iOS application fetches contacts from device using code

我的iOS应用程序使用代码从设备获取联系人

[[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.

CNContact类有一些值意味着联系人在设备上的收藏夹中(在电话应用程序中)?我没有在CNContact键中找到这样的键。

Or maybe predicate contains keys that I needs?

或者谓词包含我需要的键?

1 个解决方案

#1


2  

Filip Radelic answered same question:

Filip Radelic回答了同样的问题:

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.

收藏夹存储在Phone.app中,而不是存储在地址簿数据库本身中。你不能在非越狱的iPhone*问其他应用程序的沙盒,所以不幸的是答案是否定的。

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.

此外,如果任何应用程序可以看到您最喜欢的联系人,那将是非常糟糕的隐私。在不问你的情况下它可以访问整个地址簿已经很糟糕了。

#1


2  

Filip Radelic answered same question:

Filip Radelic回答了同样的问题:

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.

收藏夹存储在Phone.app中,而不是存储在地址簿数据库本身中。你不能在非越狱的iPhone*问其他应用程序的沙盒,所以不幸的是答案是否定的。

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.

此外,如果任何应用程序可以看到您最喜欢的联系人,那将是非常糟糕的隐私。在不问你的情况下它可以访问整个地址簿已经很糟糕了。