ContentsOfDirectory for FileProvider URLs

I'm developing an iOS app.

Through a .fileImporter I get access to a directory URL which might be provided by an external service like Dropbox (using a FileProvider).

As the user picked the URL I have full access to it.

I want to get the contents of the directory:

FileManager.default.contentsOfDirectory(
        at: url,
        includingPropertiesForKeys: keys,
        options: [.skipsHiddenFiles]
    )

Unfortunately I only get whatever files the system is currently aware of, which in case of external providers is often not much.

If the user opens the Apple Files app and navigates to the folder then the system gets the content from the external provider and back in my app contentsOfDirectory would show everything.

What can I do to get a list of the URLs?

Can I somehow trigger the system to update from the external provider? Or is there another way of handling this situation?

In general, you can register NSFilePresenter on directories or files which you are presenting in your application. This is a way to be notified of changes to those items while you are presenting them, so you may update your UI for instance. And it gives the system a notion that your app is presenting the given item.

FileProvider-based applications will automatically receive an API upcall when an application has registered an NSFilePresenter on one of their items.

Some FileProvider applications will use this upcall as a hint, to refresh the latest state from their server.

I would suggest trying this in your application and see if it helps.

Thanks for your response.

I do have a NSFilePresenter on a parent folder and get notifications for changes in the subfolder from this one. But it does not trigger any updates that I would see. It does get called, though, after I have opened the files app and the system learns about the newly added files.

Would I need another NSFilePresenter on each subfolder?

Some FileProvider applications will use this upcall as a hint, to refresh the latest state from their server.

Does that mean that in the end it would have to be the FileProvider that needs to provide support? I'm curious about how the Files app (and other apps) trigger the update.

ContentsOfDirectory for FileProvider URLs
 
 
Q