swift - 从 iOS 10.3 开始,discoverAllIdentities 和 discoverUserIdentity 为 CKUserIdentity.lookupInfo 返回 nil

标签 swift cloudkit ios10.3

CKContainer.discoverAllIdentities(completionHandler:), discoverUserIdentity(recordID: - 完成处理程序返回 CKUserIdentity 但 .lookupInfo 始终为零,即使联系人包含电子邮件、电话等。其他属性,如 hasiCloudAccount、userRecordID、nameComponents 都很好。这个问题刚刚开始发生在最近的 Swift 3.1 版本中。有谁知道这是否是预期的行为,因为我无法在发行说明中找到任何关于 CloudKit 更改的引用,但这看起来像是隐私问题。

经过进一步调查,这个问题似乎是由于最近的 iOS 10.3 更新引起的。在装有 10.2.1 的 iPhone 5 上运行该应用程序时,不会出现该问题并且 lookupInfo 正确包含 emailAddress

提交的 Apple 错误:31377433

新:此外,如果我尝试通过 CKDiscoverAllUserIdentitiesOperation 访问信息,特别是 userIdentityDiscoveredBlock -> user.nameComponents,结果是与 12 岁以下用户关联的 apple id 的“空字符串”(并且可能在“家庭共享”计划)。我没有找到关于此的信息,苹果开发支持也没有提供任何帮助。

最佳答案

由于缺少声誉,我无法发表评论,所以我必须这样做...

我也提交了相同的错误 (31397767),希望他们能修复它。

CKFetchShareParticipantsOperation 需要CKUserIdentityLookupInfo。由于没有解决方法,我们需要等待他们修复它。

我只是对这个错误感到好奇,因为如果您已经将您的应用程序提交到应用程序商店,那么整个共享部分将对用户不起作用。

更新

iOS 10.3.1 更新没有解决问题。

更新:解决方案

我收到了 Apple 关于这个“问题”的回复。这是 c&p 的答案:

This is the expected behavior, since CKDiscoverAllUserIdentitiesOperation doesn't require prompting the user for Contacts access. If you'd like to turn these results into participants you'll need to request contacts access and get the lookup info off the contacts yourself via the contactIdentifiers property.

// Identities discovered via CKDiscoverAllUserIdentitiesOperation correspond to entries in the local Contacts database. These identities will have contactIdentifiers filled out, which your app may use to get additional information about the contacts that were discovered. Multiple contactIdentifiers may exist for a single discovered user, as multiple contacts may contain the same email addresses or phone numbers.

Note that discovering users and looking up participants are two logically different things- you can only discover users that have made themselves discoverable via -[CKContainer requestApplicationPermission:CKApplicationPermissionUserDiscoverability ...], but you can get a participant for any email address or phone number even if it doesn't correspond to an iCloud account. You don't need to discover users and then turn them into participants- you can just have the user of your app enter addresses for participants to add to a share.

关于swift - 从 iOS 10.3 开始,discoverAllIdentities 和 discoverUserIdentity 为 CKUserIdentity.lookupInfo 返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43130466/

相关文章:

ios - SiriKit INPayBillIntentHandling - Siri 说, "I wish I could, but <App> hasn' t 还没有和我一起设置。”

javascript - IOS 10.3.1 Chrome 浏览器 CORS 失败

swift - 如何检查在 swift 中声明的类型为 UnsafeMutablePointer<ObjCBool​​> 的变量的值?

ios - 以编程方式检索用户的 App Store 昵称

ios - 如何从cloudkit下载多条记录

ios - 如何在保存数据之前检查用户是否登录到 iCloud

swift - 修剪后无法在相机胶卷中显示视频

ios - TableView 未知阴影错误

ios - 在 Swift 中优化嵌套 for 循环

ios - Core Data、xcode 7、实例成员和主视图 Controller