I'm attempting to write to the public container of CloudKit, but I keep getting the error message:
I've tried the different quality of service, like userInteractive, but still doesn't work.
I initialize the container in AppDelegate.swift with the standard code:
The Security Role on the dashboard shows that the creator can both read and write.
Xcode: Version 12.0 beta 6
iOS: 14.0
only when I'm accessing the container through the cellular network. When I try on a wifi network, however, it works perfectly fine and can confirm the presence of the uploaded data on the dashboard. There is absolutely nothing wrong with the cellular connectivity of my device.CKError 0x281ff9ec0: "Network Unavailable" (3/NSURLErrorDomain:-1009); "The Internet connection appears to be offline."
Code Block swift let publicCloudDatabase = CKContainer.default().publicCloudDatabase let operation = CKModifyRecordsOperation(recordsToSave: [exampleRecord], recordIDsToDelete: nil) let operationConfiguration = CKOperation.Configuration() operationConfiguration.allowsCellularAccess = true operationConfiguration.qualityOfService = .userInitiated operation.configuration = operationConfiguration operation.perRecordProgressBlock = {(record, progress) in print(progress) } operation.perRecordCompletionBlock = {(record, error) in print("Upload complete") } publicCloudDatabase.add(operation) publicCloudDatabase.save(exampleRecord) { [unowned self] record, error in if let error = error { print("public cloud database error: \(error)") } else { print("Sucessfully uploaded to Public Cloud DB") } }
I've tried the different quality of service, like userInteractive, but still doesn't work.
I initialize the container in AppDelegate.swift with the standard code:
Code Block swift lazy var persistentCloudKitContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: "Example") guard let description = container.persistentStoreDescriptions.first else { fatalError("Could not retrieve a pesistent store description") } let options = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.com.noName.Example") description.cloudKitContainerOptions = options do { try container.initializeCloudKitSchema() } catch { print("Initialize error: \(error)") } container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) return container }()
The Security Role on the dashboard shows that the creator can both read and write.
Xcode: Version 12.0 beta 6
iOS: 14.0