Swift: How to import other files to your app - ios

I am developing a file manager app , and I need to users able to import other files to my application, I searched many question but did not success !
First I register file types using : Registering the File Types Your App Supports,
But when I tap share icon on safari or photos there my app won't show in list of apps.
And then what is the next step to import files and store it to Document Directory of my app?

In iOS other apps will not just automatically communicate with your app. You have to create an extension that lets the other apps like Safari or Photos know that your app can talk to them. A basic description for this can be found in the App Extension Programming Guide.
There they also point you towards sources on how to work with the iOS file system.

Related

Xamarin iOS: What is different between Document Provider and Importing Document

I am new on iOS. In my application, I need to get files on the phone e.g. pdf, words etc in the phone. I know iOS application has their own sandbox to work with, they have no idea of other applications.
I have read some of the extension : Document Provider and a older post importing document through this link : https://mobiforge.com/design-development/importing-exporting-documents-ios
Is there any different between the two setup in my requirement? Sorry this is my first time working on iOS.
Unfortunately, iOS does not allows to share files storage between apps from two different developers.
If you own both apps, you can use App Groups to share data and files between apps. You can read more about App Groups, and how to use the APIs here https://developer.xamarin.com/guides/ios/watch/working-with/app-groups/

Is there a way to open an editor app in ios and receive edited results?

I have an app that downloads files from a web server. Our customer wants the ability to edit those files on their mobile devices and upload the edited version to our servers. Is this possible in iOS? I have figured out how to allow users to view the files in external apps, but I don't see a way to bring back their changes if the file was modified as it seems to copy the file into the other app's space, so my app is left with the unaltered version.
iOS has a sandbox mechanism, so for sure you can not modify any file in another app.
The only way to transfer data from different app is using sharing.
This is a sample project I wrote for implement sharing on iOS, check it:
Sample for sharing on iOS
Hope it can help you.

Open link from DropBox app to My App

Is there any way to open link from dropbox app to my own App ?
I want to play audio file from dropbox app to my app.
Thanks.
The solution for this isn't specific to Dropbox.
You need to setup your app to indicate that it can open certain types of files (such as audio files). Once you do that, then any app, such as the Dropbox app, that offers an "Open In" option for those types of files will show your app as one of the options.
To learn how to register your app for certain types of files, see How do I associate file types with an iPhone application?

How to access all the files(pdf, doc etc) in iOS?

How can I find out programmatically all the files present in iOS device and list them out to user? Also I need to download the file in my local application database?
How this can be achieved with Objective-C.
You cannot access all files in an iOS device outside the sandbox of the app. But there are other ways you can achieve this. What you can do is:
Access all the files in Gallery using UIImagePickerController.
Access all the user files in network- Dropbox/Google drive/iCloud. They all have separate public APIs that can be downloaded and used to download/upload files in network.
In this way, you can access most of the user files and use the same in your application.
Simple answer : you can't (on a non-jailbroken device).
Each app is launched is in own sandbox and can't interact with the others apps, expect using API provided by Apple for app-communication (ex: extension)
You should look at that Apple guide about App Sandboxing, which is valid for OSX and iOS apps.
The main difference between these two OS, as quoted directly from the doc :
iOS Note: Because it is not for user documents, an OS X container
differs from an iOS container—which, in iOS, is the one and only
location for user documents. In addition, an iOS container contains
the app itself. This is not so in OS X.
You cannot access all the files outside the app sandbox. But, if they are available at some shared location(network), you can use third party libraries to access them. For eg.
1. For iCloud- iOS provides inbuilt framework of UIDocument
2. For dropbox- DropBoxAPI is available
3. For Google drive- there is a separate library to access files in the drive.
Hope this helps :)

UTIs for the gallery App share function

I am implementing Foto/video/others import in my App.
Using the UTIs public.image, public.movie, com.adobe.pdf, etc works fine on a lot of Apps, but apple's gallery displays only Mail,Facebook,twitter and youtube in the Share function.
How to get my App in this list ?
Thanks!
Your app is a consumer (you said you are importing.) Apple's Gallery app is also a consumer AND a producer. As a producer, Gallery could share with your app as a consumer.
On the desktop (OSX) declaring the UTI's that your app supports (produces or consumes) in your app bundle is the first step. Then in what is similar to 'sharing', the Finder lets you double click a file (document) to open it with the default app (or other app) that supports the UTI. Finder is part of security (sandboxing): the user is in charge when using the Finder and the OS assumes the user understands the security implications of sharing content between apps, but the Finder may still give warnings about security.
On iOS, I suppose you are asking whether declaring UTI's in your app bundle is sufficient for the Share button? I don't know. In iOS8 apparently you need an App Extension.

Resources