How do you process multiple files shared from the iOS Files App - ios

I have an app that can open files shared with it. If I select multiple files in the iOS Files app and share them with my app, my UIApplicationDelegate's open url handler is called once with the URL of the first file. The remaining files are not reported to my delegate. Does anyone know how to get the obtain the URLs of all the shared files?
I need a solution for iOS 11 and above.

Related

How to Flutter write files to iOS iPhone "Find on my phone" Folder

My goal is to allow my app user write and read files created by my app. For example, write and then allow the user to email a .CSV file of data, or a .GPX file of location data. And on the other end, import a file back into my application.
I have successfully deployed an Android version of my app (Plant List GPS) which uses Flutter plugin path_provider 1.6.10. On Android, I successfully use external directories, but this external directories solution is not available/allowed for iOS. I find on iOS I can create subfolders and write to the getApplicationDocumentsDirectory, but when I try to find/read that file from a file picker solution, it cannot be seen. I understand this is proper behavior to protect sensitive app files in this folder location.
I also understand that iOS has the concept of an app Sandbox and appreciate its objectives. I'm not trying to defeat it, but find a way to access/use it in my Flutter app. I have played around in writing test data files to various places on the iOS file system using the iPhone 11 simulator on my MacBook, but can not get any file to appear in the phone "Find on my phone" dialog.
Any help in solution approach or technique is appreciated.
I think you need to add both the keys into info.plist, and then files from your app directory will be visible on Files app!
LSSupportsOpeningDocumentsInPlace
UIFileSharingEnabled

iOS Files App Registration with file types

I store video files in the Documents folder of my app. I need to present an option that enables users to copy video files from Documents folder to iOS Files app. I also want to automatically have a folder for my app in iOS files app (as seen in the screenshot).
I tried registering Document type "public.movie" (screenshot 2) but didn't help.
Wondering how to achieve it.

How to view document directory in iOS emulator?

I wrote a React Native application that downloads a file and saves it to the document directory.
The application gives me a path like this:
/Users/laurent/Library/Developer/CoreSimulator/Devices/SOMEID/data/Containers/Data/Application/SOMEID/Documents
and using macOS Finder I can see that the file has indeed been created.
My problem is how to view this file from the iOS emulator? If I click on the Files app for instance, I can't see that file. Basically is this file available to the user from somewhere and, if so, where? Or maybe I need to save it to a different directory?
Your iOS app is sandboxed by default, meaning that no other app can access its resources. The simulator is very different since it runs on your mac and stores your files there so you can easily access them.
That said, it is very simple to expose your Documents folder by adding the appropriate keys to your app's info.plist:
Add the UISupportsDocumentBrowser key to grants access to all the documents in the app’s Documents directory and have them appear in the Files app (iOS 11 and above). When this is enabled, other apps can also have access to your documents when using UIDocumentBrowserViewController.
Add the UIFileSharingEnabled key to expose the app’s Documents directory to the desktop iTunes app. When combined with the LSSupportsOpeningDocumentsInPlace key, it will also enable Files app support and document browser as mentioned above.
By default any files your application downloads are only available from within that app, they will not show up in the file system of the device.
As far as I know there is no react-native library which allows you to access the iOS file system, so you will need to make use of native iOS code to solve your problem. Besides pointing you to the official documentation, there is not much more I can do to help.

Having a bit of trouble with copying a local file on iOS

Having only worked with Android/web dev before I am having a hard time figuring out where in the world my file should be getting copied to in iOS. After reading the file browser documentation on the iOS developer resource page it says that each app is an "island" which contains its own folder system. If I want to have my user be able to copy a file from my app's sdk to their iOS device, where should I put it?
I downloaded a file browser app from the app store on my iOS testing device but am I right in thinking that there is no global file browsing system?
I am using a Cordova plugin called Asset2sd which works perfectly for me in Android, getting the root storage folder and downloading the file to there. It has no iOS alternative so I'm going to have to figure something else out, I just need to know where to start. Do I have to have the user access my app's internal files somehow? Can I create a folder for them to look in when they download my app? Some documentation or something would be wonderful. I am totally lost.
Thanks!
You're right. Apps don't have access to the global file system. Each app only has access to their own app directory. Here's in-depth information on Sandboxing: https://developer.apple.com/app-sandboxing/
In your app's sandbox, you basically can manage files as you want, i.e. download, copy, move, delete, etc. So you can create a folder Downloads in your apps documents directory and then display the contents of this folder for instance in a table view.
Related documentation/links:
https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html
https://stackoverflow.com/a/6907432/967327
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iPhoneAppProgrammingGuide.pdf

How to write a file from iOS8 share extension that host app can read?

I have a share extension in iOS8 that I'm invoking from Safari. After it runs it has some data that it wants to share with the main application (for which both are using a shared app group), however the data is far too big to stuff into the user settings, it needs to be stored as a file. How do I write the file such that when my main app is loaded it can see the file?
For clarity, I'm not talking about downloading a remote file, the file is created in memory by the share extension.
EDIT: Spelling correction.

Resources