2017-01-27 33 views
0

如果未在iPhone中啓用iCloud,則必須從我的應用程序打開iCloud設置。在iPhone中以編程方式從另一個應用程序打開iCloud設置

我真的很感謝你的回答,我是說。

+1

請參閱:http://stackoverflow.com/a/41162296/4350275 –

+0

它不會成爲答案,但也許你可以創建一個服務器來存儲設置,並獲取數據,如果iCloud未啓用。 – EDUsta

+0

感謝Prera​​k Sola – Sakthi

回答

0

不幸的是,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年屆715「CloudKit技巧和訣竅」,他們提出一個更微妙的方式starting about 7:30

我會喜歡在 處理應用程序中缺少的帳戶時觸及幾項最佳做法。當 遇到這種情況時,可能會引起用戶告誡 他們沒有登錄的iCloud帳戶並且無法繼續處理。 這對用戶無效,因爲他們可能會取消提醒 並重試導致他們在第一個 位置看到警報的操作。我們建議您改用 用戶界面,方法是隻需要禁用您的應用需要 帳戶的功能,爲此您現在可以使用CKAccount更改 通知重新啓用該用戶界面,當您收到它,重新檢查 帳戶狀態,並看到現在有一​​個帳戶可用。

即在參考CKAccountChange通知,在iOS的9

大概介紹不是你要找的人,但希望這有助於問題的答案。

相關問題