Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - import file from another app into my app

I want to import a document from another app into my app like it's done in MS Outlook iOS app when you click the paperclip in an email. Then you get a list of apps (dropbox, google drive etc) + recent documents and you can select a document.

How is this done / do I need to use the app-extensions for this ?

thanks Frank van Vliet

like image 739
Frank van Vliet Avatar asked Jul 15 '15 09:07

Frank van Vliet


People also ask

Can an iOS app open another app?

iOS Allows us to open some applications with some links or other ways from our app, like dialing a number when clicked on it, or writing a mail with some static body or writing a SMS. But this is limited to some applications, not every app can be opened from within an application.

Where are iOS app files stored?

On your iPhone, iPad, or iPod touch, open the Files app. Don't see the blue Files app icon on your Home Screen? Just swipe down, then search for the Files app. In the Files app, search or browse for the file that you want.

How to delete imported image Concepts?

Tap+hold the object on the pack to Edit or Delete your object.


1 Answers

this is the scope of App Extensions. To add an App Extension to your Project you have to navigate to File -> New -> Target and the App Extension you are looking for is called Document Provider. Please first check the WWDC Video on best practice for App Extensions and the App Extension Programming Guide. It will help you to develop the understanding of this Feature.


EDIT:

Maybe I set you on the wrong track, but within the App Extension Programming Guide you could have found the answer to your Question. I'm using Xcode 7.0 Beta 4, but most of the following screenshots should look exactly the same in Xcode 6.*. First of all I started a new SingleView-Application written in Swift and added the Document-Provider Extension as a target to the Project as outlined above.

new Application and Target

After building the application with the new Document Provider target I ended up starring confused onto the Share-Menu realising that we talked at cross purposes. The Documentation on this target is slightly muddled but after a while of testing and searching I realised that the thing you are looking for is the Document Picker, not the Document Provider. On this Page you can find the Relevant Chapter: Accessing Documents Link, where you can get examples for the Document Picker.


Since this will hopefully solve your Problem, I would like to shortly refer to the Document Provider and the overvalue it could add to your Application.

The Document Provider extension consists of two separate parts: the Document Picker View Controller extension and the File Provider extension. The Document Picker View Controller extension provides your document provider’s user interface. The system displays this interface when the host app presents a document picker view controller for your document provider. This interface should let users browse through and select documents and destinations from inside your document provider. This extension can also perform basic import and export operations without any additional support.

from the App Extension Programming Guide as mentioned above

So the Document Provider is kind of an Import Feature as seen from another app. If you would implement a Document Provider Target for your Application, other Apps can access designated data. For example you could attach Files from your App to an E-Mail (left screenshot) or Open a File in Pages (right Screenshot).

Open File in other Apps

When working with Files, this could be a nice feature for your users.


Also I would recommend using either a Share or a Action Extension.

Share extensions give users a convenient way to share content with other entities, such as social sharing websites or upload services. For example, in an app that includes a Share button, users can choose a Share extension that represents a social sharing website and then use it to post a comment or other content.

That doesn't sound exactly like the thing you want to achieve, but at the moment even Apple uses the Share Extension for all kinds of things.

An Action extension helps users view or transform content originating in a host app. For example, an Action extension might help users edit an image in a document that they’re viewing in a text editor. Another type of Action extension might let users view a selected item in a different way, such as viewing an image in a different format or reading text in a different language.

You said you want to import a document from another app into your app. This sounds handy. Lets assume a user opens a Document "loremIpsum.txt" in the iCloudDrive Application and wants to share it to your new app.

Action Extension

Now, you have to write the code to handle imported files when opened by the Document Picker, you could reuse this code to easily add a Action Extension to the Share-/Action-Menu. I hope this will help you and solves more than one problem.

Best regards

cr0ss

like image 148
cr0ss Avatar answered Oct 10 '22 15:10

cr0ss