Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to same files from two different apps on iOS

Tags:

ios

ios6

I have two apps I'm developing at the moment, App1, which is downloading files from Dropbox to the iPad, and App2. The Dropbox integration is a bit of a hassle, and I'd rather not do it on both apps. So is it possible to save those files from App1 somewhere that App2 might access them? I've heard that the Sandboxing of apps got a bit looser in iOS6, but not really sure how loose.

I've seen some similar questions here, but they seem to be solved by using URL schemes or sending data to the other app, which isn't really what I'm after.

Any other ideas to solve this will be appreciated.

like image 708
peirix Avatar asked Oct 30 '12 19:10

peirix


2 Answers

This is possible, but the local method isn't really suitable for large files.

You can use the Keychain to store small amounts of data, similar to NSUserDefaults. The advantage is this can be shared between applications. Refer to http://shaune.com.au/ios-keychain-sharing-data-between-apps/

As for your case, where you want to share files, you could encode them to a string and store in the keychain (in my opinion a very bad idea), or use a web service (if you're targeting iOS 5 and above, iCloud should do the trick as long as you have the same Team ID for both apps). Refer to http://developer.apple.com/library/ios/#documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html

I'd prefer the web service, iCloud should make this a lot easier for you.

like image 105
WDUK Avatar answered Oct 24 '22 07:10

WDUK


There is another way you could do this, although it's a very ugly way of doing it, because it makes your information visible to the user (after a fashion, anyway).

One of the only mediums that can be stored, read and write to the same place on the same device is images. You can, in fact, write your information (file, array, web service cache, whatever you want) as the pixel information of an image. Then you can store it without compression locally to a custom album and the other app can access the 'images' in the album and interpret them as the original file. You would have to roll your own header information for you image to indicate the file format, etc, and the user would be able to see the image, although it would mostly look like total nonsense. This is a form as stenography.

Anyway, i don't expect you to accept this as the answer, but I thought i would raise it as a demonstration that with some creative coding you can get around most barriers :)

like image 26
Bergasms Avatar answered Oct 24 '22 09:10

Bergasms