如何确定CNContact是收藏夹? [英] How can I determine that CNContact is is favorites?

查看:159
本文介绍了如何确定CNContact是收藏夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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
    }
  }
}];

CNContact类的某个值是否意味着联系人位于设备上的收藏夹中(在Phone应用程序中)?我在CNContact键中找不到这样的键.

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?

推荐答案

Filip Radelic 回答了相同的问题:

收藏夹存储在Phone.app中,而不存储在通讯簿数据库本身中.您不能在未越狱的iPhone上访问其他应用程序的沙箱,因此不幸的是,答案是否定的.

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.

这篇关于如何确定CNContact是收藏夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆