Search code examples
iosswiftaccountmanager

how to determine the users CKAccountStatus


Im trying to figure out how to determine the users iCloud status. I've read the developer reference outline and I still can't figure out how to determine this. Heres the code that I have extracted and tried to use in my app but it does not do anything as far as I can tell:

            enum CKAccountStatus : Int {
                case CouldNotDetermine
                case Available
                case Restricted
                case NoAccount
            }

I've been at this for awhile now and I know I'm missing something but I can't seem to figure out what it is! Please help!


Solution

  • You need to call CKContainer's accountStatusWithCompletionHandler which determines the status of the current user’s iCloud account asynchronously.

    See the CloudKit Framework Reference for the CKContainer Class

    https://developer.apple.com/library/prerelease/ios/documentation/CloudKit/Reference/CKContainer_class/index.html