【问题标题】:Open iCloud settings from another app programmatically in iPhone在 iPhone 中以编程方式从另一个应用程序打开 iCloud 设置
【发布时间】:2017-01-27 12:56:56
【问题描述】:

如果 iPhone 中未启用 iCloud,我必须从我的应用程序中打开 iCloud 设置。

我真的很感谢你的回答,我是认真的。

【问题讨论】:

  • 它不会作为一个答案,但也许你可以创建一个存储设置的服务器,并在未启用 iCloud 的情况下获取数据。
  • 感谢 Prera​​k Sola

标签: ios objective-c iphone ios10


【解决方案1】:

很遗憾,Apple 没有提供执行此操作的方法。官方的 iCloud 设计指南有一个部分 Alert the User to Enter iCloud Credentials 仅包含以下内容:

[[CKContainer defaultContainer] accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error) {
     if (accountStatus == CKAccountStatusNoAccount) {
         UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Sign in to iCloud"
                                                                   message:@"Sign in to your iCloud account to write records. On the Home screen, launch Settings, tap iCloud, and enter your Apple ID. Turn iCloud Drive on. If you don't have an iCloud account, tap Create a new Apple ID."
                                                            preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"Okay"
                                              style:UIAlertActionStyleCancel
                                            handler:nil]];
        [self presentViewController:alert animated:YES completion:nil];
    }
    else {
        // Insert your just-in-time schema code here
    }
}];

然而,在 WWDC 2015 Session 715 “CloudKit Tips and Tricks”中,他们提出了一种更微妙的方法starting about 7:30

我想谈谈几个最佳实践 在您的应用程序中处理丢失的帐户。什么时候可能很诱人 遇到这种情况会向用户发出警报 他们没有登录的 iCloud 帐户,无法继续。 这对用户没有帮助,因为他们可能会忽略警报 并重试导致他们在第一时间看到警报的操作 地方。相反,我们建议您优雅地降级您的 UI 以一种简单的方式禁用您的应用程序需要的功能 一个帐户,为此您现在可以使用 CKAccount change 通知以重新启用该 UI,当您收到它时,请重新检查 帐户状态,并查看一个帐户现在可用。

这是对 CKAccountChange 通知的参考,在 iOS 9 中引入。

可能不是您要找的答案,但希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 2014-01-17
    • 2010-10-18
    • 1970-01-01
    • 2013-05-16
    • 2011-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多