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/
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
似乎无法为此找到有效的答案。我正在阅读Rails教程的第10章第10.1.2节,但似乎无法使邮件程序预览正常工作。我发现处理错误的所有答案都与教程的不同部分相关,我假设我犯的错误正盯着我的脸。我已经完成并将教程中的代码复制/粘贴到相关文件中,但到目前为止,我还看不出我输入的内容与教程中的内容有什么区别。到目前为止,建议是在函数定义中添加或删除参数user,但这并没有解决问题。触发错误的url是http://localhost:3000/rails/mailers/user_mailer/account_activation.http://localhost:3000/rails/mai
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在检查一个Rails项目。在ERubyHTML模板页面上,我看到了这样几行:我不明白为什么不这样写:在这种情况下,||=和ifnil?有什么区别? 最佳答案 在这种特殊情况下没有区别,但可能是出于习惯。每当我看到nil?被使用时,它几乎总是使用不当。在Ruby中,很少有东西在逻辑上是假的,只有文字false和nil是。这意味着像if(!x.nil?)这样的代码几乎总是更好地表示为if(x)除非期望x可能是文字false。我会将其切换为||=false,因为它具有相同的结果,但这在很大程度上取决于偏好。唯一的缺点是赋值会在每次运行
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
可能已经问过了,但我找不到它。这里有2个常见的情况(对我来说,在编程Rails时......)用ruby编写是令人沮丧的:"astring".match(/abc(.+)abc/)[1]在这种情况下,我得到一个错误,因为字符串不匹配,因此在nil上调用[]运算符。我想找到的是比以下内容更好的替代方法:temp="astring".match(/abc(.+)abc/);temp.nil??nil:temp[1]简而言之,如果不匹配,则简单地返回nil而不会出错第二种情况是这样的:var=something.very.long.and.tedious.to.writevar=some
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上
我在思考流量控制的最佳实践。我应该走哪条路?1)不要检查任何东西并让程序失败(更清晰的代码,自然的错误消息):defself.fetch(feed_id)feed=Feed.find(feed_id)feed.fetchend2)通过返回nil静默失败(但是,“CleanCode”说,你永远不应该返回null):defself.fetch(feed_id)returnunlessfeed_idfeed=Feed.find(feed_id)returnunlessfeedfeed.fetchend3)抛出异常(因为不按id查找feed是异常的):defself.fetch(feed_id
我正在构建一个应用程序,想知道是否将未使用的对象设置为nil是生产级编码中的常见做法。我知道这只是垃圾收集器的提示,并不总是处理对象。 最佳答案 根据这个thread如果您使用完一个成员对象,将其设置为nil将引发被引用对象被垃圾回收。如果它是局部变量,方法exit将做同样的事情。也就是说,如果您要求将成员显式设置为nil,我会质疑您的设计。 关于ruby-将对象设置为nil是否很常见?,我们在StackOverflow上找到一个类似的问题: https://