How to check Quota exceeded in CloudKit

I want to prompt users when their iCloud storage quota is full. My test device's iCloud space is full, and when subscribing to the NSPersistentCloudKitContainer-eventChangedNotification event, events exceeding the quota will not be passed to the application at runtime.

When I tried to add data to Core data using NSPersistentCloudKitContainer, I got an error:

<CKError 0x600000c15890: "Quota Exceeded" (25/2035); server message = "Quota exceeded"; op = 1ECF73B9554DF79F; uuid = 34D12DF0-A307-49EB-AD3A-BB646FF66F54; Retry after 316.0 seconds>}>

My iCloud storage space is full, but I am unable to retrieve the 'Quota exceeded' error.I have written a demo, please help me fix the issue.

github: CloudKit Sync Demo

Full CloudKit error:

CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:](3372): Finished request '<NSCloudKitMirroringExportRequest: 0x2838102d0> DBF6E860-3AC7-4D37-AC1D-2128059CF1B2' with result: <NSCloudKitMirroringResult: 0x281593210> storeIdentifier: 0BBE4F61-D1FC-4100-A94D-FE5033DEB1FC success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134410 "(null)" UserInfo={NSUnderlyingError=0x281547960 {Error Domain=CKErrorDomain Code=2 "CKInternalErrorDomain: 1011" UserInfo={ContainerID=iCloud.app.yu.TodoTest2, NSDebugDescription=CKInternalErrorDomain: 1011, CKPartialErrors={
    "<CKRecordID: 0x281bb47e0; recordName=1AA0232D-5834-45C1-A857-03E76ED15131, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x281547300: \"Quota Exceeded\" (25/2035); server message = \"Quota exceeded\"; op = 0FAD62529ED394B9; uuid = AA83D27C-581F-4E78-9B1A-7FBD9618F76C; Retry after 316.0 seconds; container ID = \"iCloud.app.yu.TodoTest2\">";
    "<CKRecordID: 0x281bb44e0; recordName=27C5E07B-3B67-4D81-A55C-6D15BF466239, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x281547780: \"Quota Exceeded\" (25/2035); server message = \"Quota exceeded\"; op = 0FAD62529ED394B9; uuid = AA83D27C-581F-4E78-9B1A-7FBD9618F76C; Retry after 316.0 seconds; container ID = \"iCloud.app.yu.TodoTest2\">"

I posted about the same issue before and also filled feedback. But this is still an issue: https://developer.apple.com/forums/thread/830420

Thanks for reporting the issue. Yeah, this is a known issue: (CKError 25/2035: "Quota Exceeded") is nested inside the CloudKit operation's internal partial failures dictionary, and NSPersistentCloudKitContainer does not preserve or populate partialErrorsByItemID (or CKPartialErrorsByItemIDKey in userInfo) on the public Event.error object delivered through eventChangedNotification.

I’d still suggest that you file your own feedback report to voice the impact, which may help the framework folks to prioritize the issue.

Before the issus is fixed from the framework side, the only workaround I can see is that you use CloudKit API directly to write data to the CloudKit database, detects and handle the CloudKit error, if any, and then remove the data. This is obviously far from ideal, however.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

How to check Quota exceeded in CloudKit
 
 
Q