Open a file in an external App on iOs


I know that in iOs I can register the file types my App supports using the CFBundleDocumentTypes key in the info.plist property list file. In an App I need to do the inverse process. I need to know if there are other apps that supports PDF files and open a file from my App in the target external App (ie Adobe Reader). I saw a lot of iOs apps that supports this functionality, like dropbox or google drive: in these apps I can select a PDF and open it in Adobe Reader (if installed on the device) or in any other app that support PDF. How can I manage this situation in Titanium? I searched in the api documentation but I didn't find anything to read a system list of registered provider app. Any idea?

4 Answers

  • hi,

    you can use Ti.Platform.openURL to open file with installed app.

    — answered 3 years ago by Mitul Bhalia
    • Thank you Mitul, but it's not what I mean. I want to open the file with a specific app, in this case adobe reader. If i use Ti.Platform.openURL I cannot do this, I cannot choose with which app open the file. I need to check if there are apps that have registered themself as PDF file provider, using the CFBundleDocumentTypes key. If you try dropbox or google drive for ios (iphone or ipad) if adobe reader is installed you can choose to open a file with that instead of the internal viewer.

      — commented 3 years ago by Salvatore Guarino
    • oh…..then i have not yet faced this situation so do not know but if there is no way to do this in titanium then you can create a native module to do that…

      what say…? :)

      — commented 3 years ago by Mitul Bhalia
    • I'm not able to create a native module because I'm not an Objective-C developer :) Do you think that titanium is not able to access to these ios system properties?

      — commented 3 years ago by Salvatore Guarino
    • you can set your custom info.plist in titanium …

      see this

      — commented 3 years ago by Mitul Bhalia
    • Thank you, I understand this, but I need to do the opposite thing. I don't need to tell to iOs that my app support PDF, I need to know which apps that are installed on the device support PDF. My app is not a PDF reader, I need to open PDF using Adobe Reader. I hope I was clear…

      — commented 3 years ago by Salvatore Guarino
    • ok…

      — commented 3 years ago by Mitul Bhalia
  • Hi Salvatore, i think your question is having good point and Titanium does not support this feature by default.

    Using Native module approach it is possible and As you are not Objective C programmer , so take help from some body.
    Here is a helping code in stack overflow

  • Thank you, I understand that this is the only way to do that.

  • I had the same problem and searched all over for "Open in" solutions in Titanium. The solution was simpler than I thought.

    var docViewer = Ti.UI.iOS.createDocumentViewer({url:'Example.pdf'});{animated:false,view:btnShare});});

    I'm using Titanium SDK 3.0.2