YapDatabase icon indicating copy to clipboard operation
YapDatabase copied to clipboard

CloudKit: Getting a notification on upload progress/finish and retrieving CKRecord system fields

Open uthiel opened this issue 9 years ago • 1 comments

My app uploads potentially big files as CKAsset to iCloud via the YapDB CloudKit extension. I'd like to get notified about the progress of the upload and once it has finished. Apparently, two notifications are sent when an upload finishes, one YapDatabaseModifiedNotification, but it only contains the YapDatabaseSnapshotKey and YapDatabaseConnectionKey keys, for which I'm unable to retrive info about the uploaded object from, for example a yapDatabaseModifiedNotificationCustomObject I had stored earlier, and a YapDatabaseCloudKitInFlightChangeSetChangedNotification but the userInfo is null.

Here is some code which I use to add a CKAsset to the db which was uploaded to the device by the user via iTunes file sharing:

	TSAsset *asset = [[TSAsset alloc] initWithType:item.dbType dataURL:dataURL previewURL:prevURL];
	[transaction setObject:asset forKey:asset.dbKey inCollection:asset.dbCollection];
	transaction.yapDatabaseModifiedNotificationCustomObject	= dataURL;

After the upload has finished, I'd like to extract the dataURL from a notification, in order to remove the source file for the CKAsset from disk. How can I achieve this from the two notifications that are sent?

Progress info seems to be absent completely. Would it be possible to add this?

uthiel avatar Nov 20 '16 00:11 uthiel

I'm trying to access CKRecord system fields, for example creationDate. These fields are only populated after a record has been stored to the server. So in addition to above problem specifically regarding CKAssets, I'm now looking for a way to get notified after any record has been uploaded to iCloud.

I have been observing YapDatabaseModifiedNotification and YapDatabaseCloudKitInFlightChangeSetChangedNotification and they do fire before and after the record has been uploaded to iCloud, but the CKRecord that is contained in the notification that fires before upload does not contain any system fields and the notifications that fire after upload both don't have the userInfo dictionaries set, so how am I supposed to access the relevant record? I can't enumerate thousands of records every time I get a notification.

uthiel avatar Dec 06 '16 06:12 uthiel