iOS App-to-App Trasnmission of Data using new Document Support API
Asked Answered
A

1

7

Problem:


Building Enterprise Applications of a Suite Nature, and need to be able to pass data from one application to another. Example: App1 is a barcode reader that produces and inventory list. App2 needs a "fresh" copy of the same inventory list information that App1 just produced in order to accomplish its goal of producing purchase orders. The two apps and databases are two large to squeeze together in single app, plus the suite will continue to grow with more and more apps.


Understanding:


I fully understand that "Each" application is in it's own sandbox. However, in reading through the documents regarding the new UIDocumentInteractionController API, it appears that an application can dip outside of the sandbox just a little to "Read-In", "View", or "Open-In" a document that was not apart of the bundle or created within the application.


Data Flow:


I'm trying to keep it simple. I have been using the DocInteraction sample application downloaded from Apple, and another application...called App1 to try and work with a simple text file. In App1, I create a simple txt file, and save it to the documents folder. (But this is still inside the app's sandbox?). in the DocInteraction modified sample, I have been trying to figure a way to "View", "Open-In", or better yet "Read-In" the created txt file. If I can pass a simple txt file between the two, I can include a CSV structure to update the databases on each side when ever the applications are opened.

I have tried to utilize the Launch Options Keys with no luck.

In short, I just can't seem to get my head around:

  1. Where App1's data needs to go?
  2. How to find the data in the other App, say App2?
  3. How do you "Open" the file that exist inside another application's sandbox?

End Result: I have tried to stay away from the

The Document Interaction docs outline:

  • Previewing a Document or Presenting Options
  • Registering Your Support of File Types
  • Opening Files From Other Apps
  • Displaying and Printing Quick Look Previews

It is the "Opening Files From Other Apps" that I am most interested with. It directs me to utilize the application:didFinishLaunchingWithOptions: method by passing in dictionary values for the keys. This is where I get lost?? How do I set the keys so that it knows "WHERE" and "WHAT" to look for? And I'm still not clear the proper director that App1 should be saving information to in order for the keys to point to the correct place?


Opening email file attachments and opening pdfs in iBooks can't be the only places where you can utilize this API or else Apple wouldn't have went through all the work, they are already allow to talk from App-To-App.


Note: I'm not trying to get App1 to directly transmit data into App2's files. I don't think that would be allowed by Apple at all! I'm trying to get App1 to zip up its data, save it in proper location, so when user decides to use App2, the data can then be available to App2 by "reading-in" the data.

If someone has a sample application, tutorial, or even a solid idea how to get this working I would really appreciate the help.

-Thanks!

P.S. Somebody with 1,500 or higher reputation please create a "UIDocumentInteraction" tag for stackoverflow!

Autogamy answered 26/1, 2011 at 5:17 Comment(0)
D
7

I got it working last month. Here's my mental model:

App1 creates a file anywhere in its sandbox.

App1 calls docinteraction to display the "Open In" GUI for that file

User picks "Open in App2"

The iOS copies the file from one sandbox to the other and launches App2.

App2 implements didfinishlaunchingwithURL and loads the supplied URL (which is the copy in its sandbox)

Dissonance answered 26/1, 2011 at 22:53 Comment(5)
The Documents directory would be the appropriate place; even if it makes no difference now, I suggest using the directory for future potential functionality.Succubus
Thank you for the logic clarification. How does the "didFinishLaunchingWithOptions:" get the launching URL which I assumes points back to the original file's name and location? Does a full file copy actually get copied, packaged, and sent over to the second document...or just the URL where to find the original? If the full file is copied, it is possible to have the copy dropped and left in App2's documents folder so that App2 can use it upon subsequent loads on its own? or does the the file get deleted or snatched back right after the user in App2 switches screens or is done viewing?Autogamy
The launching URL points to the COPY in App2's sandbox. It is a full copy (must be, your app can't read files outside of it). I think it stays there until App2 chooses to delete it.Dissonance
- App1 calls docinteraction to display the "Open In" GUI for that file - User picks "Open in App2"..... How do you perform the 2 steps? I can't find any documentation/code snippets :(Injury
developer.apple.com/library/ios/ipad/#documentation/UIKit/…Dissonance

© 2022 - 2024 — McMap. All rights reserved.