I have an application where I want to save some user data on iCloud, using CloudKit, and the private database.
The problem is, I received feedback of app crashing if the user iCloud has reached it's storage limit.
I can't reproduce it because I don't have an iCloud account with the database full.
I wanted to check the storage available in the private database on the user logged, so if it has no more storage capacity, make the app work different, but I don't find anything that explains how to check the private database available storage.
Is there some method that I can't find? Or is this impossible? what happens if the private database is full and I try to add or update some record?
Your attempt to save a record is likely resulting in the error CKErrorQuotaExceeded
. Detecting and handling this error is the best (and, currently, only) way to determine if saving a record will exceed the user's current storage quota.
Even if there were a way to check the currently-available iCloud storage, it wouldn't solve the problem - nothing prevents the available storage from changing between the time you retrieved the value and the time you try to save a record. The proper approach is to handle the error code when saving.