Why is iCloud account/CKContainer not being found
According to the documentation,
The private database is available only when the value in the ubiquityIdentityToken property is not nil.
It also says
There are times when iCloud may not be available to your app, such as when the user disables the Documents & Data feature or signs out of
iCloud.
Documents and Data is now apparently what is called iCloud Drive in Settings.
So I would ask the users in question if their iCloud Drive setting is enabled and if turning it on makes any difference.
CKContainer fetchUserRecordIDWithCompletionHandler returns nil CKRecordID when iCloud Drive is disabled
It's working as designed. iCloud Drive is a requirement to use CloudKit. This is documented in the CloudKit Quick Start.
Look under the Enter iCloud Credentials Before Running Your App section.
CKContainer accountStatusWithCompletionHandler returns wrong value
Figured out, iCloud Drive was turned off for the app.
iOS No iCloud account is configured
I logged out of iCloud and logged back in and then in worked.
@matt answered correctly
CloudKit and iCloud account
if users don't have an iCloud account they won't be able to update the public database?
From Apple's Designing for CloudKit doc:
Saving records to the public database and accessing the private database in any way requires the presence of an active iCloud account on the device.
So you're right.
can the apple account (the one the user needs to download stuff from the apple store) wouldn't be enough to update the public database and gain access to the private database?
This is a slightly unclear question - cases where an Apple ID is set up to download from the App Store and isn't set up for iCloud are very rare. I would assume that nearly all devices that can download your app likely have an iCloud account attached to them.
Cloudkit Authentication Only works on my alt account and not Dev or Tester accounts
It was a bug with CloudKit. Sometimes the container can be broken on creation apparently.
I was able to fix it by creating a new container in Xcode (on the config screen for your app) and unchecking the old one. Then I configured the new container from scratch, adding all the data types and configuring the security roles (roles take like 5min to kick in so just keep checking/trying).
Check if User is Logged into iCloud? Swift/iOS
Here you go - hopefully self explanatory. For more look at the Apple docs for the NSFileManager function below.
func isICloudContainerAvailable()->Bool {
if let currentToken = NSFileManager.defaultManager().ubiquityIdentityToken {
return true
}
else {
return false
}
}
See extract below:
An opaque token that represents the current user’s iCloud identity (read-only)
When iCloud is currently available, this property contains an opaque object representing the identity of the current user. If iCloud is unavailable for any reason or there is no logged-in user, the value of this property is nil.
Related Topics
Swiftui Sheet Gets Dismissed the First Time It Is Presented
Hex String to Text Conversion - Swift 3
Swift Generics Protocols: Can Only Be Used as a Generic Constraint Problem
Adopting Customnserror in Decodingerror
Realmswift Initialize List:Cannot Specialize a Non-Generic Definition
Xcode Generated Coredata Files Cannot Be Processed by Copy Bundle Resources Build Phase
Can a Condition Be Used to Determine the Type of a Generic
Add a Xib File to a Swift Package
Cannot Load Module Coredata as Coredata
Difference Between Optional Values in Swift
Spritekit: Howto Make Holes in Layer with Blendmode
How to Implement a 'Next' Property to a Caseiterable Enum in Swift
Saving Coredata to a Web Server with Swift 3.0
How to Make a Segue to Second Item of Tab Bar