NSFileProviderExtension How to show download progress

I have implemented most parts of the NSFileProviderExtension.

In "startProvidingItem", I created a "urlsessiondownloadtask".


let task = downloadsSession.downloadTask(with: request)


and attached it to NSFileProviderManager


NSFileProviderManager.default.register(task, forItemWithIdentifier: identifier, completionHandler: { (error: Error?) in })


But when I click the file, the progress of download stays at zero byte.

How can I properly display the download progress in NSFileProviderExtension?


Thanks

Accepted Reply

Hello guys, I found the solution for this problem. You have to configure your NSURLSession properly to see the download progress.

It has to be configured in this way:


- The URLSession should use a .background configuration.

- The configuration should have a valid sharedContainerIdentifier.

- The container app of your extension should have the access to the shared container.

- The extension should report the right file size via the documentSize property.



NSURLSessionConfiguration *config=[NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:item.filename];

config.sharedContainerIdentifier=@"YOUR_CONTAINER";

_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];

Replies

I am seeing the same behavior.

Same issue here. Any ideas?

Yes same with me I have registered the task but it shows no progress only empty progress bar with stop button inside

I had to pile on but I am also seeing the same thing. Did anybody come up with a solution? I see it works fine in Dropbox.

Hello guys, I found the solution for this problem. You have to configure your NSURLSession properly to see the download progress.

It has to be configured in this way:


- The URLSession should use a .background configuration.

- The configuration should have a valid sharedContainerIdentifier.

- The container app of your extension should have the access to the shared container.

- The extension should report the right file size via the documentSize property.



NSURLSessionConfiguration *config=[NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:item.filename];

config.sharedContainerIdentifier=@"YOUR_CONTAINER";

_session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];