Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS15 B4 NSPersistentCloudKitContainer "Account Temporarily Unavailable" Error

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)")
            }
        })
    }
like image 662
ryannn Avatar asked Jul 28 '21 08:07

ryannn


2 Answers

This appears to be a bug introduced on beta 4 - https://developer.apple.com/forums/thread/685857

like image 177
ryannn Avatar answered Oct 21 '22 19:10

ryannn


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 = ***-***-***>.

like image 45
thisIsTheFoxe Avatar answered Oct 21 '22 20:10

thisIsTheFoxe