I check if user is logged into iCloud, if not I set a alert. But instead I want to send the user to appropriate settings, where user can actually log into iCloud and once logged in is complete redirect to current view controller.
How to I modify this code?
var iCloudStatus:Bool = false
func ifUserLoggedinToICloud() -> Bool {
let alertController = UIAlertController(title: "Alert", message: "iCloud Status", preferredStyle: .alert)
defaultContainer.accountStatus(completionHandler: { (accountStatus, error) in
if (accountStatus == .available) {
print("iCloud is available")
iCloudStatus = true
}
else {
print("iCloud is not available, log into iCloud")
alertController.message = "iCloud not available, log into iCloud"
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(alertController, animated: true, completion: nil)
}
})
return iCloudStatus
}