iOS应用程序到应用程序使用新的文档支持API传输数据 [英] iOS App-to-App Trasnmission of Data using new Document Support API

查看:238
本文介绍了iOS应用程序到应用程序使用新的文档支持API传输数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:



构建套件的企业应用程序,需要能够将数据从一个应用程序传递到另一个应用程序。示例:App1是生成和库存列表的条形码读取器。 App2需要App1刚刚生成的相同库存列表信息的新鲜副本,以便完成其生产采购订单的目标。这两个应用程序和数据库是两个巨大的单一应用程序挤在一起,再加上套件将继续增长与越来越多的应用程序。





理解:



我完全理解每个应用程序都在它自己的沙箱中。但是,在阅读有关新的UIDocumentInteractionController API的文档时,看起来应用程序可能只在沙盒外面读入,视图或打开一个不分开的文档或在应用程序中创建。





数据流:



我试图保持简单。我一直在使用从Apple下载的DocInteraction示例应用程序和另一个应用程序... App1来尝试使用一个简单的文本文件。在App1中,我创建一个简单的txt文件,并将其保存到文档文件夹。 (但这仍然在应用程序的沙盒里?)。在DocInteraction修改的示例中,我一直在试图以一种方式来查看,打开,或更好的读入创建的txt文件。如果我可以在两者之间传递一个简单的txt文件,我可以包括一个CSV结构来更新每一侧的数据库,当应用程序打开。



我试过



简而言之,我似乎无法得到我的头脑:



  1. 如何在App2中找到数据? b
  2. 如何打开另一个应用程序沙箱中存在的文件?

结果:





  • 从其他应用打开文件

  • 显示和打印快速查看预览



这是强>>我最感兴趣。它指示我利用应用程序:didFinishLaunchingWithOptions:方法通过传递键的字典值。这是我失去的地方?我如何设置键,使它知道WHERE和WHAT寻找?我仍然不清楚适当的导演,App1应该保存信息,以使键指向正确的地方?





在iBooks中打开电子邮件文件附件和打开pdf文件不是唯一可以使用此API的地方,否则Apple不会完成所有的工作,他们已经允许从应用程式至应用程式。
注意:让App1直接将数据传输到App2的文件中。我不认为这是苹果所允许的!我试图让App1压缩其数据,将其保存在正确的位置,所以当用户决定使用App2时,数据可以通过读入数据可用于App2。






如果有人有一个示例应用程序,教程,甚至一个坚实的想法如何让这个工作,我真的很感谢帮助。



- 谢谢!



有人拥有1500或更高的声誉,请为stackoverflow创建一个UIDocumentInteraction标签!

解决方案

这是我的心理模型:



App1在其沙箱中的任何地方创建一个文件。



App1调用docinteraction 打开该文件的GUI



用户选择在App2中打开



iOS复制文件从一个沙箱到另一个沙箱并启动App2。



App2实施didfinishlaunchingwithURL并加载提供的URL(其沙箱中的副本)


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!

解决方案

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)

这篇关于iOS应用程序到应用程序使用新的文档支持API传输数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆