iOS - How to send file from one app to other specific app - ios

I want to send .pdf or image file from my app1 to app2 like instagram hooks. I don't want to show options. I want to send the file directly from app1 to app2 if app2 is installed.
At first I tried using custom URL schemes by modifiying this example. It is good for sending some strings but I couldn't find I way to send files with custom URLs. I've tried to encode file to base64 string and appending to URL. It didn't work. URL becomes broken.
Then I searched for implementing UIDocumentInteractionController Uti as Instagram and WhatsApp does. But I couldn't find any sufficient examples. This is the right way I guess but there isn't much information to go on.
How could I achieve this with the methods mentioned above? (App groups, keychain, pasteboard are not good options for me)

This is very old question, but I think, you tried to find something like this:
If you would like other applications to open your app based on a file type, you can register your document request in the application plist file. This provides a means to associate any file type with your iOS app.
Include the CFBundleDocumentTypes key, which is an array of dictionaries, where each entry defines information about the file type(s) your app supports.
Here are some useful links:
iOS Tips and Tricks: Associate a File Type with your App
How to register file types supported by an iOS app
How To Import and Export App Data Via Email in your iOS App

Related

How to declare vcard document type in xcode plist file

I would like my App to open for VCards (.vcf format). I know that the type is known as public.vcard and has mime-type text/vcard.
How is this type registered in the info.plist?
I have declared many custom types (UTI) and that works for me, but the VCard is a known format and so far I did not manage to set it up. When I for example airdrop a vcf file, then iOS Contacts shows up, but not the "open with" dialog.
There is a similar question already, but the proposed solution does not work: https://stackoverflow.com/a/16506340/4180386
Some of the types handled by system apps that provide API access to the data (photos, contacts, calendars, etc) seem to only offer the system app as an airdrop destination. Other types work fine and result in the “open with” alert as you pointed out.

How to show all apps receives strings in "Open In.." menu?

I'm totally new in iOS development. I'm developing an app processing some strings in UItextview. After the process, I want show "Open In.." menu with all applications can receive text values.
To explain more. What I mean is like this in Android http://developer.android.com/training/sharing/send.html
I took a quick look at the link you posted.
Apple enforces a "sandbox" around apps which greatly limits what you can do.
Off the top of my head here are a few ways to do it:
Define a custom URL scheme in each of your apps. One app would open a URL using the other app's URL scheme, and that would open the other app and pass it the URL.
For a family of apps from the same company you should also be able to set up a common base "bundle ID" and use that to read and write shared entries to the keychain. The keychain is limited to fairly short bits of data however. (It's intended for password strings and the like.)
I haven't used it before, but you should also be able to use the UIDocumentInteractionController class to pass a copy of a document between apps. As I understand it, the sending app presents a document and asks the user to pick an app with which to open the document. When the user picks a target app, the system creates a copy of the document in the target app's documents directory and then tells the target app to open it.

forcing a file to open in predefined application in iOS

I am trying a simple web app which downloads files from internet and saves on iPad. Theses files are of .pdf,.xls,.doc, etc format. Now, I want to assign a default application to open a specific file type. (Say Adode reader for pdf file, Some image viewer app for image files etc). I dont want my app/os to decide which app the file should open in. Instead, if assigned app doesnt exists then it should give me a message that no such app found. Is it possible to do?
With a web app you cannot do such things.
If you go native, you can use Custom URL Schemes (see http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html)
But with Custom URL Schemes, you only are able to pass a view parameters. If you want more, UIPasteboard is recommended.
Apps are sandboxed. You cannot access other apps, nor their data!!!
But on native apps you can pass over data with pasteboard, call a custom url handler, pass a few parameters to cause the other apps to process your data.
Often App developers, like camera+ offer a documentation for the usage of their custom url schemes (Camera+ URL Schemes API)

Is it possible to have access to the image specified in CFBundleURLIconFile via URL scheme from a different iOS app?

is it possible to access the icon specified with CFBundleURLIconFile in the info.plist file from a different application? Does application sandboxing prevent it? If so,what is the purpose of this key(in an iOS app of course)?
Thanks
As stated in CoreFoundationKeys docs: "CFBundleURLTypes contains an array of dictionaries, each of which describes the URL schemes (http, ftp, and so on) supported by the application. The purpose of this key is similar to that of “CFBundleDocumentTypes,” but it describes URL schemes instead of document types."
The purpose is to permit applications to register for some type of documents allowing an app to handle the opening of files from other installed app (you surely met the "Open In..." button, for example in Mail when you receive a file).
More on this in the Document Interaction Programming Topics for iOS.
EDIT:
Sorry, I forgot to answer to your main question: AFAIK the only way to access that key is through UIDocumentInteractionController.

How can I transfer files from one application to another in the same iOS device?

I am writing an iOS application that performs conversion of a file saved by another application on the same device to another format. How can I transfer files from one application to another in the same device? Note that the files are non-textual files.
UIDocumentInteractionController is your friend.
Basically it works like this:
App 1 registers as being able to handle files of type XYZ
App 2 implements UIDocumentInteractionController and will give users the options to "send the file to App1" (I believe this has to be user activated)
App 1 implements -(BOOL)application:openURL:sourceApplication:annotation: and deals with the transferred file which will be saved in your Documents/Inbox directory. From there you can copy the file elsewhere and then manipulated it, making sure you clean up by getting rid of the original one saved on the Inbox folder.
Class reference available here
Document interaction programming guide available here
If you are developing both apps, you can store shared information in the keychain as long as your bundle identifiers conform to the same bundle seed id. See here for more info. Of course, if you are making both applications, you can use a URL scheme to pass in base64 encoded data as well.
Update: As rog said below, UIDocumentInteractionController is great, but it is only available for 4.2 and up, so you are cutting out a major portion of your users if you want to use it.

Resources