I have to open iCloud settings from my app if iCloud is not enabled in iPhone.
I really appreciate your answers, I mean it.
I have to open iCloud settings from my app if iCloud is not enabled in iPhone.
I really appreciate your answers, I mean it.
Unfortunately Apple doesn't provide a way to do this. The official iCloud Design Guide has a section Alert the User to Enter iCloud Credentials that just contains this:
[[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
}
}];
However, in WWDC 2015 Session 715 "CloudKit Tips and Tricks" they suggest a more subtle approach starting about 7:30:
I would like to touch on a couple of best practices when handling a missing account in your apps. It might be tempting when encountering this situation to throw up an alert for the user telling them they don't have a logged in iCloud account and can't proceed. This is not helpful to the user because they might dismiss the alert and retry an operation that led them to see the alert in the first place. What we recommend instead is that you gracefully degrade your UI in a way that simply disables the features of your app that require an account, and for this purpose you can now use CKAccount change notification to re-enable that UI, when you receive it, re-check the account status, and see that one account is now available.
That is in reference to the CKAccountChange notification, introduced in iOS 9.
Probably not the answer you were looking for, but hope this helps.