So working on an app that uses CloudKit (private database). Now, the app is allowed to run in "local mode" if the user is not using iCloud or has disabled iCloud for my app.
Now imaging this case:
1) iCloud is not enabled for my app and the user starts creating data.
2) The user subsequently enables iCloud for my app.
3) My app gets a CKAccountChangedNotification.
4) My app starts uploading local data the user created before iCloud was enabled to CloudKit.
5) My app gets a CKErrorQuotaExceeded when uploading data.
6) My app displays an alert, telling the user he has run out of iCloud storage and he can either Buy More in iCloud Settings or turn off iCloud for the app to run in "Local mode."
So now my app is in this state where iCloud is enabled but the user has no iCloud storage left. I don't see any API to tell if iCloud storage changed. If the user goes to Settings, buys more storage, and goes back to my app, I'd like to retry sending the local data back to Cloudkit for initial sync. I guess I just have to retry the operation every time the app is launched and show the error over and over again until the user does something about it (disable iCloud in Settings or buy more storage)?
Ideally, I'd like to give the user an option to turn off iCloud (for my app only) in app when the error is hit, because telling them to navigate to Settings to turn off iCloud is hard for a lot of people. Or present a system provided view controller offerring them to upgrade their iCloud storage plan. CKStoragePurchaserViewController?
#pragma mark - CKStoragePurchaserViewControllerDelegate
-(void)storagePurchaserViewControllerDidPurchaseAdditionalStorage:(CKStoragePurchaserViewController*)vc
{
//retry sync.
}
-(void)storagePurchaserViewControllerDidDisableICloudFunctionality:(CKStoragePurchaserViewController*)vc
{
//iCloud is now off, run the app in local mode.
}