iOS - Download file & launch with default app?
(Titanium newbie, so apologies if I've missed something obvious)
Is there a mechanism by which I can pass iOS a local file path, and have (whatever app is appropiate) open that file?
EDIT #2: I managed to hack together a very rough draft which does work @ http://pastie.org/1352776
Note that the picker doesn't properly launch and it has other problems, but it does actually launch.
EDIT: Browsing the iOS docs, I see that the proper way to do this is via a document interaction controller - http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html#//apple_ref/doc/uid/TP40010410-SW1
But I'm still stuck as to what titanium calls this functionality, or how to trigger it!
Background:
I'm trying to create a test app which
1) downloads a file [this works fine, using a modified kitchen sink example]
2) launches that file with whatever iOS thinks should run the file (ie: the PDF viewer for PDF, whatever it uses for ppt's, gallery for images, etc)
I had (perhaps naively) hoped I could just pass openURL the downloaded file and that it would magically work, but it silently fails.
Can someone point me in the right direction? The goal is something like dropbox - ie it stores several files, which you can then click to open in whatever app should open that file.
Thanks for any pointers anyone can give.
W.
4 Answers
-
Can't you just embed a webview and set the url to the local path?
-
here is a sample I wrote which should solve the problem for you
-
William,
I'm curious to know if you ever got this working properly. I started with you demo code no matter what I try I still get the weird invisible dialog behavior.
Thanks,
Erik -
I'm also looking to do this. Has anyone built a module that works in this fashion? Im surprised this doesn't exist yet. Perhaps my searching skills are lacking. Doug? :)