Skip to content

Instantly share code, notes, and snippets.

@insidegui
Last active July 27, 2018 19:01
Show Gist options
  • Save insidegui/5523796b377133a637855e837acfbb7d to your computer and use it in GitHub Desktop.
Save insidegui/5523796b377133a637855e837acfbb7d to your computer and use it in GitHub Desktop.
Obtaining the user's iCloud account status using CloudKit
CKContainer.default().accountStatus { status, error in
if let error = error {
// some error occurred (probably a failed connection, try again)
} else {
switch status {
case .available:
// the user is logged in
case .noAccount:
// the user is NOT logged in
case .couldNotDetermine:
// for some reason, the status could not be determined (try again)
case .restricted:
// iCloud settings are restricted by parental controls or a configuration profile
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment