CKContainer accountStatusWithCompletionHandler returns an invalid value

accountStatusWithCompletionHandler returns .NoAccount . Any idea why the return value is not .Available ? I connected to iCloud and connected to the Internet.

Doc says .NoAccount means:

An iCloud user account is not available because no account was provided for this device.

I do not get any errors. Maybe this application does not use a private database? Doc says:

Call this method before accessing a private database to determine if the database is available.

+3
source share
2 answers

Revealed that iCloud Drive has been disabled for the application.

+2
source

This sample code shows the status with iCloud. Perhaps request permission or a promotional user to log in .NoAccount . I think this is the case when you are not connected to iCloude.

 let container = CKContainer.defaultContainer() container.accountStatusWithCompletionHandler({status, error in switch status { case .Available, .Restricted: container.requestApplicationPermission(CKApplicationPermissions.PermissionUserDiscoverability, completionHandler: { applicationPermissionStatus, error in // handle applicationPermissionStatus for statuses like CKApplicationPermissionStatus.Granted, .Denied, .CouldNotComplete, .InitialState }) case .CouldNotDetermine, .NoAccount: // Ask user to login to iCloud } }) 
0
source

All Articles