How to track down an iCloud upload properly?

200 views Asked by At

I am trying to integrate iCloud usage in my app. I did understand how the process works and its basis. I was already able to upload content to iCloud but I need to track down the uploading progress in order to improve the Ux that I am providing to the end user.

So, basically I upload the document using the method below:

- (void)saveToURL:(NSURL *)url forSaveOperation:(UIDocumentSaveOperation)saveOperation completionHandler:(void (^ __nullable)(BOOL success))completionHandler __TVOS_PROHIBITED;

Before I call this method, I am also initialising a MetadataQuery. This query is specific and it is supposed to get the progress of a document passing the document's name and its URL as parameters. Something like this:

- (void)startMonitoringMetadataQueryWithBackupName:(NSString *)backupName andBackupURL:(NSURL *)backupURL;

Method implementation:

enter image description here

After doing this, I am only receiving events triggered by NSMetadataQueryDidStartGatheringNotification and even so, the received info does not bring any usable value.

I was expecting to receive events from the NSMetadataQueryDidUpdateNotification, bringing the MetadataQuery with results in order to get the NSURLUbiquitousItemPercentUploadedKeyvalue. However, I am not receiving any notification of this type and I am not able to monitoring the upload progress.

Am I missing something? I am out of ideas because this seems so simple and it does not work as expected.

(Note: I also need to implement a similar behaviour when a document is downloaded and I think the approach will be the same, just changing the query's valueListAttributes. I am afraid this problem will persist when I am implementing it)

Thanks

0

There are 0 answers