0

I'm looking at different ways of transferring data between iOS apps, for instance UrlScheme, Shared Keychain, UIActivity, Custom Url etc..

However I would like to knnow what's the best way of passing large amounts of data between apps, such as 1 or 2 photos, as well as some standard text data. iCloud is not available.

Can anyone provide advice on which one is the best of these methods for this task given that the data can be quite large?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Fittoburst
  • 2,215
  • 2
  • 21
  • 33
  • 1
    If you only need support for iOS 7 then look into the new Multipeer Connectivity framework. – rmaddy Feb 04 '14 at 18:02
  • Multipeer Connectivity permits sharing of data between apps on the same device? – Gruntcakes Feb 04 '14 at 18:28
  • @Mungbeans Perhaps I misread the question. My comment was meant for transferring data between devices running the same app. – rmaddy Feb 04 '14 at 19:47
  • @Fittoburst Do you need to transfer between apps on the same device or between two devices? If on the same device, are both apps by the same developer? Use `UIPasteBoard` with a privately named pasteboard if transferring on the same device between two apps written by the same developer. – rmaddy Feb 04 '14 at 19:48
  • @Maddy It is transferring large amount of data (photos + text) between different apps on the same device. – Fittoburst Feb 04 '14 at 22:52

2 Answers2

1

Presumably you already found this link - the 4th answer sums up pros/cons of the options you asked about: Share data between two or more iPhone applications

The first thing that came to mind for me was adding "Open In {Some Other App]" functionality, since that's pretty much the standard interaction users have come to expect since iOS6. Whether or not that's "best" I suppose depends on what you want to do w/the data/images in the 2nd app...

The 1st/"sending" app subclasses and manages UIActivityViewController. This is where you customize the options you want to make available (like "Open in 2nd App", "Print", etc). You use a UIActivityItemProvider subclass to wrap the data you want to send. This conforms to the UIActivityItemSource protocol to handle callbacks, etc. You can create a custom file type, or use a common one the 2nd app supports.

The receiving app registers a supported file type w/the system. This can be a custom type/extension you define, or it could be a common format like JPG, PNG, etc, as long as you actually send that type and the receiving app tells the system it handles that type of file.

"Absolute Ripple" has an in-depth 3-part tutorial about the process to customize wrapping & sending data via UIActivityViewController to another app (social media & mail in this case): http://www.absoluteripple.com/1/post/2013/06/customising-activity-view-controller-mail.html

"The Other Steve Smith" in this blogpost does a quick rundown of creating/registering a custom Uniform Type Identifier or file type, along w/a custom graphic for your target app. http://stevenpsmith.wordpress.com/2013/03/11/using-custom-file-types-to-import-data-into-your-ios-apps/

Maybe not at all what you're looking for, but if so I hope that helps

Community
  • 1
  • 1
mc01
  • 3,750
  • 19
  • 24
  • Basically, the first app will collect data such as user name/address and one or two relevant photos. This needs to then be 'transmitted' to a second app which will collect the data, store in database and synchronise with external services. It seems the UIActivityViewController would be the best. Is it correct that I can create my own 'type' of file which will contain my data and then my custom second app will be the only one to appear as it is the only one that recognises that file type? – Fittoburst Feb 04 '14 at 23:10
  • It would be much, much easier just to integrate the basic data collection & camera access into the 2nd app, but if that's how it has to be ... Yes, the last link above discusses the process of creating a custom file type & setting up an app to recognize it. – mc01 Feb 05 '14 at 19:08
0

If you need to transfer only Photos, you can use Camera roll.

  1. Save image to Camera Roll using ALAssetsLibrary which will provide assetURL in completionBlock.
  2. Transfer image assetURL to second app ( with lunchOptions for example )
  3. Load image in second app.
Gago
  • 297
  • 1
  • 9
  • How does the second app delete the photo after its loaded? Assuming the app(s) want to tidy up after their transfer – Gruntcakes Feb 04 '14 at 18:33
  • I am afraid it can not. But this is the way to transfer images in offline mode – Gago Feb 04 '14 at 18:41