10

I have an iPhone app that some of my users are running on their iPad in emulation mode. We're thinking about creating an iPad-optimized app, as well, which would be a separate app in the App Store (more features, different price point).

The problem is: if a user is running the iPhone app on an iPad and then they purchase our iPad-optimized version, how can they migrate their data out of the iPhone-only app and into the new iPad app?

Here are some alternatives I've considered:

  • As recommended in other SO questions, the secure keychain. The problem is that this only allows a small chunk of data to be transferred. Our users are likely to have tens of megabytes of data
  • Registering URI schemes (also suggested in other SO questions, also appears to be designed for only very small amounts of data)
  • Let the user upload the data from the iPhone-only app to a service like Dropbox or box.net, then from the iPad version, download that data again. Advantage is that these services have very straightforward APIs; disadvantage is that the user may need to create an additional account and/or download another app just to move data
  • Create an iCloud document. No signup required, but setting up iCloud storage is, to put it lightly, nontrivial

Are there any other options for transferring tens of megabytes of data between two apps on the same device.

Bill
  • 44,502
  • 24
  • 122
  • 213
  • What's your evidence on the assertion that URI schemes are only for small amounts of data? Is there a length limit on URLs passed from app to app? Otherwise you could just base 64 encode your data and put whatever you want in there. I don't think there's a base 64 encoder built into the API (though they're really easy to write), but there's an implicit decoder since NSURL supports `data:` URLs and `NSData` can load from them. – Tommy Mar 06 '12 at 07:50

3 Answers3

13

You can use a UIDocumentInteractionController to let the user open a document in any app on the device that has registered support for the document type.

This will still make a copy of the document in the iPad app's sandbox. There's no getting around that.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • What details do you need that aren't in the guide I linked? – rob mayoff Mar 02 '12 at 04:54
  • Well, for example: how does the new iPad app get a path or handle to the document in the other app? The description in the guide suggests that you can open files only when your app delegate is launched with particular arguments. This sounds like a promising way to do it (no remote transfer involved, no separate accounts) but I've never heard of UIDIC being used in this way. – Bill Mar 02 '12 at 13:49
  • The system will send `application:openURL:sourceApplication:annotation:` to your [application delegate](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40006786-CH3-SW26) when the user has chosen it to open a document. You receive this after `application:didFinishLaunchingWithOptions:` if you weren't already running. – rob mayoff Mar 02 '12 at 18:18
  • I guess my question is: how does the process as a whole work? Does the iPad app present a UIDIC with some filter that will include a file from the iPhone-only app? How do I get a URL/path to a file in another app's sandbox? Does the original iPhone app get the app delegate methods or the iPad app? This is an intriguing hint, but I'm still not able to see if it solves my whole problem. – Bill Mar 03 '12 at 18:11
  • Create the controller in your iPhone app. If the user chooses to open the document in the iPad app, the system will copy the file to the iPad app's sandbox. – rob mayoff Mar 03 '12 at 18:29
  • You could even detect the presence of the iPad and iPhone apps from the respective other app via an URI scheme. If you open the iPad app for the first time and it detects the iPhone app, open a special "transition" URI for the iPhone app. When the iPhone app is started with that URI (or detects that the iPad app exists), it uses the document API to offer to open the document via the iPad app, thus transitioning the data. – pmdj Mar 11 '12 at 16:32
1

Albeit a bit more work is required, but given the amount of data to be transferred is relatively small, you could set up a server as the middle man. The biggest benefit to this is that people can also transfer data between their iPhone and iPad instead of just intra-iPad.

It could be as simple as a "transfer to iPad" button which then prompts the user to create a temporary username and passkey, and then transfers the data to an SQL database. Then on the iPad side, all you'd have to do is sync the data, authenticate, and download. The database could be purged of data greater than ten days old to keep its size from growing.

Peter Kazazes
  • 3,600
  • 7
  • 31
  • 60
  • Unfortunately, as I mentioned, we're talking about tens of megabytes of data. It would take too long to send that up and down, would use up my users' data plans and would require me to pay for a bunch of cloud storage. I'm looking for a way to transfer data without it leaving the device. – Bill Mar 09 '12 at 17:52
  • @Bill tens of megabytes doesn't take too long on wi-fi, and providing good service costs money :) – Ricardo Tomasi Mar 11 '12 at 15:21