0
首先我知道这个职位:How to identify iCloud logged in user in airplane mode?手机处于飞行模式时如何检测iCloud用户?
虽然它似乎没有答案。一个答案是关于检测互联网连接的问题,另一个答案是关于用户是否改变了。
这里是我的代码:
container.accountStatusWithCompletionHandler{
(status: CKAccountStatus, error: NSError?) in
dispatch_async(dispatch_get_main_queue(), {
var title: String!
var message: String!
if error != nil{
title = "Error"
message = "An error occurred = \(error)"
} else {
//title = "No errors occurred getting info"
switch status{
case .Available:
message = "The user is logged in to iCloud"
title = "GOOD"
print("determined status was available")
self.shouldPullFromICloud()
//self.displayAlertWithTitle(title, message: message)
case .CouldNotDetermine:
message = "Could not determine if the user is logged" +
" into iCloud or not"
title = "BAD"
self.noUserIsSignedIn()
case .NoAccount:
message = "User is not logged into iCloud"
title = "BAD"
self.noUserIsSignedIn()
case .Restricted:
message = "Could not access user's iCloud account information"
title = "BAD"
self.noUserIsSignedIn()
}
print(title, message)
}
})
}
似乎很愚蠢的,你需要一个互联网连接,看是否有用户登录到iCloud中。我怎样才能解决这个问题?
谢谢!
P.S. 如果那篇文章确实包含了我的问题的答案,请您为我突出显示它吗?我找不到它。干杯!
我用这其他原因,但我仍然需要得到用户的ID不管的方式,如果他们是在飞行模式或不遐知道吗? – lelephant