Import multiple files in app via iOS11 files app
Asked Answered
H

1

18

I am trying to import multiple files from the new iOS11 files app into my app. However when I select two or more files (both of the same type, pdf) in the files app then hit the share button and select my app (copy to myApp) the

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options

gets called only once and only the first file of my selection gets imported successfully.

So I tried if this works in some other apps like Dropbox or GoogleDrive but it results in the same behavior. If I choose the iOS Mail app or the Gmail app (after hitting share in the files app), all of my selected files are imported (as attachment). So I think there must be a way to achieve this in my own app also.

Holoenzyme answered 9/11, 2017 at 13:41 Comment(3)
There is an answer here which when modified can be of use : #9973759Tab
can you please share your code snippet?Tangram
@Holoenzyme can you please give me idea for how do i open files app into my application , actually i want to import video to my app, so please give me some hintMastiff
T
3

The files that are being imported by the application are actually copied into a directory called “Inbox” within the apps Documents directory. Do you see multiple files there after importing these? I think it's possible the delegate method is only called once but if you correctly keep track of existing/new files in the Documents Inbox Directory you can correctly import multiple files :)

EDIT: These days the folder is not called 'Inbox' but the name of the folder seems to be the BundleID of your App.

Tenenbaum answered 21/11, 2017 at 14:13 Comment(7)
In my case the files where located in the tmp/BUNDLE_ID-Inbox folder. But nevertheless you solved my problem.Holoenzyme
@Holoenzyme ah ok it's possible that's been changed of course since iOS11 (or perhaps earlier). But good to hear it solved your problem! :)Tenenbaum
@BobdeGraaf does it still behave this way as of iOS 11.2.1? I find that even with multiple selections, exactly only one file is actually ever imported to the Inbox directory. I can even reproduce it with real-world apps like Procreate or PDF Expert.Knipe
@Knipe I've justed tested it myself and perhaps Apple broke something again... It seems indeed to only work with their own Apps and all other Apps like Dropbox fail. Slack even crashes everytime.. So not sure what happens, perhaps we need to create some Radars.Tenenbaum
@BobdeGraaf thanks for the confirmation. Here’s mine: rdar://36505593Knipe
@Knipe Any update on this issue? Do you have any solution?Meadowsweet
I've tried to list all files in the tmp/BUNDLE_ID-Inbox folder and there is only the first of multiple selected files copied in it, the other files are not copied.Petrapetracca

© 2022 - 2024 — McMap. All rights reserved.