4

I am using this code below (in AppDelegate) to successfully open/receive a single file when the file in question has my app's custom extension and is tapped from the Files App.

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

    let sharedItem = FileItem()
    sharedItem.path = url
    sharedItem.name = url.lastPathComponent
    sharedItem.image = self.loadUIImage(fileURL: url)

    let pickFilesViewController = self.window?.rootViewController as? FirstViewController

    pickFilesViewController?.selectedFiles.append(sharedItem)

    pickFilesViewController?.filesTableView.reloadData()

    return true
}

Now when I select multiple and similar files from within the Files app and tap the share button, my app appears under the app options with the text "copy to myapp". However, when I tap it, on my app's end I only receive the first one (appended)

How I can receive all of the selected files?

This Question has some suggestions but they don't work as it appears the path all the files are sent to isn't always the inbox folder depending on a number of factors i am yet to determine.

I've determined that opening email attachments successfully send the files to the inbox folder. But it seems selecting and thus sending multiple from the Files App send to an entirely different folder.

When I've tried to open that containing folder of the first selected/sent item so that i iterate through and get the rest.... I get the error stating my app didn't have permission to access that folder

Again, is there anyway to get all the files at once? Thanks.

Asiimwe
  • 2,199
  • 5
  • 24
  • 36
  • Try to put files in let documents = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true) let tempDocumentsDirectory: AnyObject = documents[0] as AnyObject – ares777 Apr 25 '19 at 08:14
  • Did you find a solution? @Asiimwe – Taiwosam Oct 25 '20 at 01:10

1 Answers1

4

There doesn't seem to be a way to do this currently without directly accessing the folder that it's being stored in - which isn't really something I feel okay with.

In my app, we allow our share extension to accept multiple files at the same time and have it handled accordingly. You could probably try that while you wait for apple to give us something

Sparr
  • 361
  • 1
  • 12