iOS - import file from another app into my app - ios

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

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.
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).
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.
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

Related

Android: one app for multiple uses via parameters in AndroidManifest

It is possible to register one (Delphi) app for multiple uses, with more than one icon in App Chooser? For instance like this:
register app to open some file types (I know how to do that)
register to open/acces to any file, but App Chooser should show icon different than main app icon, and different text, not the app name - for instance "Base 64 encode/decode file"
same thing, for text files or other documents/images compatible with operation - "Convert to pdf"
All functionality is built in the same app, but operation, and icon in the App Choser, should depend of parameter passed in intent, as EXTRA_TEXT for instance. For instance, if EXTRA_TEXT is "b64enc" the app should auto encode the file on intent EncodedPath, then save base 64 encoded file in app documents folder, notify user "conversion complete", then close itself.
For example, app can use file extension to choose what to do with the file, but this is not enough for functionality I need.
I have seen this answer
Multiple Application Files in one Android app
and it is OK as some kind of guidance, but not really an answer on this question :-)
In Windows the same application can register itself in Win context menu for multiple purposes with different icons and different context menu text, and same program can do different operations on the file, depends on parameter passed to the program.
So, it is possible in Android, maybe via AndroidManifest, or I shoud use different approach? And if I must, is it possible to have multiple activities in Delphi app for Android?
Edit: I have found this blog
https://blog.andreamagni.eu/2019/02/how-to-add-android-app-shortcuts-to-a-fmx-application/
and looks like maybe it is possible by using shortcuts

ios - Control copy and share file with other apps in qlpreviewcontroller or UIDocumentInteractionController

Current implementation.
UIWebView is added to a view and file is loaded in that. Here I can control copy option with "UILongPressGestureRecognizer" and also control whether to allow sharing with other apps using "documentInteractionController presentOpenInMenuFromRect".
Problem
But MS word or Excel password protected files cannot be opened in UIWebView.
Solution
Solution I found to this protected file is open them using "qlpreviewcontroller" or "UIDocumentInteractionController"
But I cant figure out a way to still control thos copy and share with other apps behaviour.
From Apple documentation:
When a document is passed to another application, the contents of the document interaction controller’s annotation property are passed with it.
So, You can subscribe to UIDocumentInteractionController delegate and change annotation of UIDocumentInteractionController to pass additional data to application.
Determination of capability to open is made based on the document type (as indicated by the uti property) and on the document types supported by the installed apps.
If You want to filter list of applications check this question.

UIInputViewController - Disable Keys Based on User Input in Container App

So, let's say I have a container app and an extension to that app for a custom keyboard. Let's say that custom keyboard has, by default 5 keys. Doesn't matter what those keys are.
Now, I want the user to be able to DISABLE any of the 5 keys in the container app. If disabled in the container app, the keys should appear red and disabled in the keyboard.
My question is: How do I load the user preferences/serialized data from the container app, into the UIInputViewController?
If anyone could help with steps necessary to make this happen, or provide a link to a tutorial (I can't seem to find one), it would be much appreciated.
So I finally figured it out.
Here are the basic steps.
1) Create a Shared Group. This link provides step by step instructions on how to do that: https://stackoverflow.com/a/29051138/1152868. I had initially implemented these steps but I was still unable to access the shared directory (outlined in https://stackoverflow.com/a/26050187/1152868) from the extension. Turns out you have to add the entitlements file to both the container app AND the extension target. That was the biggie for me.
2) Once you confirm open access across your container app and the extension, you can share data between em. I referred to this tutorial for sharing: http://www.atomicbird.com/blog/sharing-with-app-extensions. You have two options: using a shared file directory or using a shared NSUserDefaults domain. In my app, I was saving and loading data with NSCoding. But, I experienced issues with unarchiving the data in the extension, so I decided to save to NSUserDefaults instead (the data I need in the extension can be formatted as a simple dictionary, so it was easy enough).
Using Shared Groups and NSUserDefaults, I am now able to save and load data from the container app to the extension!

Component configuration file in xcode?

Lets say i want to develop an RSS Reader reusable component for iOS with a configuration file which can me updated by user. So my wish list is as follow:
Add the component to a new project in single click. Just like adding framework.
I also want that my source files are NOT visible to other user (developer).
And yes if there are resources associated with it should also seamlessly be added to new project.
And most importantly I want the developer to be able to adjust few parameters for my component eg specifying the URL for my RSS Reader.
In short after i am done all i want the developer to see are my header files and configuration file. Any ideas ?
You should use a fake framework as described here.

Custom file types with iOS Document Interaction Programming

I understand the basic of Document Interaction Programming and UIDocumentInteractionController and I've got it working in my app. However I'm having trouble with specific details of using custom file types. I can't find this addressed in the Apple docs anywhere.
My app uses it's own file types with unique extensions. The files themselves are just plists (xml), but I want the device to treat the files as only openable in my app. Originally I implemented the Document Interaction stuff to treat them as XML while I got it working, but now I want it to treat them as binary files that it needs to hand off to my app.
At the moment, if you have one of my files in an email attachment, iOS first shows the QuickLook (which just spews all the text content of the xml out) before you can choose to Open In. Similarly if one of my files is opened with Safari, Safari just shows the XML and doesn't give you the option to show it in my app at all.
So how do I get iOS to not treat my files as XML? I've changed the "Conforms to UTI" value and "public.mime-type" value in the info.plist, but it seems to have no effect.
Any tips greatly appreciated.
As far as i understand the UIT concept of Apple you cannot just change the file extension to change a potential UIT of the file. If the file contains XML-Data, other apps as well as internal apps might recognize your content and show it internally as XML.
Try to store your Plists with NSPropertyListSerialization NSPropertyListBinaryFormat_v1_0 (then you readble XML)
When you did that without success, why not trying this:
use zlib to compress the XML plists afterwards to a zipped file.
make a "unique" file extensions (<file>.myappname)
this should "hide" other apps and quick view.
Tell me if one of the ways did work for you.

Resources