Document Interaction Controller - ios

My app is supposed to be able to read and edit PDF, DOC and TXT file formats, so I decided to use another application (let me name it as app2) to open and edit files from my application.
But when I save the file in app2, file gets saved into sandbox of the app2. Is it possible to make app2 save files into my application's sandbox?

The application sandbox secures all of the files for that application... So unless you've gotten some sort of jailbroken phone you're basically going to have 1 app with 1 sandbox (i.e. 1 set of files). However, there are certain dependencies you can take advantage of from within your app. (e.g. you can do things like open a PDF using a WebView if you have iBooks or a PDF reader installed on the phone, or boot the user off to Safari to open a web link)

Related

How to allow user to upload attachments in iOS application

In case of Android when I want to send or attach a document such as a pdf or doc from my application I can easily access all the files in the external storage and share or attach.
But since iOS follows a sandbox approach as well as there is no filesystem so it is not possible to attach or upload in same manner.
In my iOS application right now, I have implemented Open In functionality, wherein in the info.plist file I have specified that my application supports all types of documents so when the user opens any documents he gets an option to Open In my application, then I save that document in the
Documents/Incoming
folder in the application, now when my user clicks to add attachment then he can see the document to attach, since this is a long process I was looking for better ones.
I saw whatsApp allows uploading/sharing from iCloud apart from that what can I do to provide a similar behaviour as Android.

Phonegap 3.0+ How to print a document and/or send it to another device via email/airdrop/etc without using Mobile Safari

I'm working on a Phonegap 3.1 iOS app.
What I have currently:
I'm using the InAppBrowser plugin to view user-uploaded documents from a server.
The document types users upload are commonly (but not limited to) the following:
.pdf
.png, .gif, .jpeg
.xls, .doc, .ppt
.txt
What I want to do:
Viewing the files works well in the InAppBrowser, but now I am exploring ways that users could send the documents to each other.Mobile Safari has a share button that allows a user to send a file by airdrop, message, mail, tweet, facebook or airprint. I cannot, however, use Safari since it is a non-negotiable requirement that I do not expose the URL where these files are hosted.
The InAppBrowser allows me to hide the location from the user, which is not possible with Mobile Safari. I want to be able to email and print a document without ever exposing the url where that document lives.
Is it possible to create the same sharing mechanism from within a Phonegap app?
What I know so far
I'm aware of the Phonegap File plugin for uploading and downloading files.
If I were to download a file from the server so it was stored locally, how would I go about making it shareable (through email, airdrop, etc)?
From what I can tell, there are no relevant Phonegap 3.0+ compliant plugins to achieve this so I would think I need to create my own. Am I on the right track?

How to Impliment Browse functionality in ios

I want to Implement Browse functionality in my Ipad App.
Actually My requirement is,When i chick on button need to open the all document are existed in device same like as "widows my computer".After Browsing that document,Select any document and I need to Upload the selected document to server.
You only have access to the "sandbox" of your application. It is by default an empty folder. It is called the application documents folder (see here how to get it). Unfortunately, unless you have a jailbroken phone, you have (mostly) no access to other folders.
If you populate this folder with files you can certainly show them in your UI and send them to a server.

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)

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