Reputation: 1557
I'm using NSPersistentCloudKitContainer on iOS15 beta 4 to sync core data across devices. When launching on device, logged into iCloud, I receive the following error in the logs:
<NSCloudKitMirroringResult: 0x28167ae60> success: 0 madeChanges: 0 error: <CKError 0x2818a94d0: "Account Temporarily Unavailable" (1028/2011); "Account temporarily unavailable due to bad or missing auth token">
I have the following code:
init(inMemory: Bool = false) {
container = NSPersistentCloudKitContainer(name: "AppName")
if inMemory {
let storeDescription = NSPersistentStoreDescription(url: URL(fileURLWithPath: "/dev/null"))
container.persistentStoreDescriptions = [storeDescription]
} else {
let storeURL = URL.storeURL(for: "my.app.group", databaseName: "AppName")
let storeDescription = NSPersistentStoreDescription(url: storeURL)
storeDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.my.app")
container.persistentStoreDescriptions = [storeDescription]
}
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
}
Upvotes: 6
Views: 558
Reputation: 1713
As @ryannnn pointed out it seems to be a bug that seems to be fixed in beta 5. I had a similar problem specifically with the public CK database. I'll edit this, if I can confirm that b5 fixed it for me...
EDIT: it did fix the Account Temporarily Unavailable
issue. However, the iCloud sync still only happens while in the first session after app install. When running it again, after it's installed I still get <CKError 0x281fe43f0: "Server Rejected Request" (15/2027); server message = "Custom zones are not allowed in public DB"; op = *****; uuid = ***-***-***>
.
Upvotes: 1
Reputation: 1557
This appears to be a bug introduced on beta 4 - https://developer.apple.com/forums/thread/685857
Upvotes: 4