【发布时间】:2017-06-25 08:50:55
【问题描述】:
我有一个应用被拒绝,因为我测试了用户是否可以访问他们的 CloudKit 容器。
如果他们没有连接,我会发出警告,并告诉他们退出应用程序。
我不可能是唯一一个经历过这种情况的人。任何人有解决方法吗?
谢谢..
有关信息,我用于测试的代码是由 Apple TSI 工程师发送给我的。叹息..
这里是:
func isICloudContainerAvailable()->Bool {
print(#function)
CKContainer.default().accountStatus { (accountStatus, error) in
if accountStatus == .available {
print(#function, "accountStatus 1: ", accountStatus)
return
} else {
print(#function, "accountStatus 2: ", accountStatus)
}
DispatchQueue.global().asyncAfter(deadline: .now() + 0.3) {
guard error != nil, accountStatus != CKAccountStatus.available else {return}
print( #function, "accountStatus 3: ", accountStatus)
print("iCloud account is not available! Be sure you have signed in iCloud on this device!")
}
}
if FileManager.default.ubiquityIdentityToken != nil {
print("User logged in")
return true
}
else {
print("User is not logged in")
return false
}
}
这里用到了函数:
if !isICloudContainerAvailable() {
let alertController = UIAlertController(title: "Uh-oh", message: "You must be signed into iCloud \nto use this app.\nPlease quit, log in to iCloud using the 'Settings' app\nand try again", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
})
【问题讨论】:
-
您收到的实际拒绝信息是什么?
-
这一次,我居然接到了一个电话。解释是我不能强迫人们登录 iCloud。我提出要求人们使用他们的 Apple ID 登录,但这也是不可接受的。