检查用户是否登录到iCloud?斯威夫特/ iOS版 [英] Check if User is Logged into iCloud? Swift/iOS
问题描述
有没有办法让我查看用户是否在打开应用程序时登录iCloud?如果他们没有登录,我希望能够将他们引导到设置页面,如果他们登录到iCloud并且之前使用过该应用程序 - 我想跳过登录页面....
Is there a way for me to check and see if a user is logged into iCloud when they open the app up? I want to be able to direct them to the settings page if they are not logged in, and if they are logged into iCloud and have used the app before - I want to skip the sign in page....
我查看了Apple的iCloud和Cloudkits文档,但无法找到任何有用的东西!这甚至可以吗?
I looked into Apple's iCloud and Cloudkits documentation but was unable to find anything that would be of assistance! Is this even possible to do?
推荐答案
在这里你 - 希望自我解释。有关NSFileManager函数的Apple文档,请参阅下面的内容。
Here you go - hopefully self explanatory. For more look at the Apple docs for the NSFileManager function below.
func isICloudContainerAvailable()->Bool {
if let currentToken = NSFileManager.defaultManager().ubiquityIdentityToken {
return true
}
else {
return false
}
}
参见下面的摘录:
一个不透明的标记,代表当前用户的iCloud标识(只读)
当iCloud当前可用时,此属性包含一个表示当前用户身份的不透明对象。如果iCloud因任何原因不可用或没有登录用户,则此属性的值为nil。
See extract below: An opaque token that represents the current user’s iCloud identity (read-only) When iCloud is currently available, this property contains an opaque object representing the identity of the current user. If iCloud is unavailable for any reason or there is no logged-in user, the value of this property is nil.
这篇关于检查用户是否登录到iCloud?斯威夫特/ iOS版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!