3

I'd like to hear your ideas/suggestions for a feasible solutions to the following scenario:

  • There is an external web service that would serve an iPad user a custom format file of my choice/design to be downloaded via the Safari browser on a user's iPad.

  • The browser would not open this file, but would instead invoke myApp to read it and use its content (the uuid code to initiate its internal processes with its value)

I've looked into this and I know now how to register "myApp" to handle a custom file extension in iOS level. This works fine as long as the file is not a text file (ie if it's a true binary file, I get the "open in myapp" prompt)

As soon as the file is recognized by Safari as text file, its contents gets displayed on the page and the user doesn't get the opportunity to "Open in in myApp" as it does with a binary file of the same extension.

any ideas/suggestions are appreciated to put me on the right track. thank you.

EarlGrey
  • 2,514
  • 4
  • 34
  • 63
  • If you create a custom file format and register your app for it, Safari will automatically present the option to the user similar to opening a PDF in Safari and it offering to open it in iBooks or another installed application. – Ryan Poolos Feb 12 '13 at 18:17
  • I've tried this and the browser would just open the file as soon as it detected it was a text based file. regardless of its extension. perhaps this option appears after the browser displays the content of the custom (but text based) file ? – EarlGrey Feb 12 '13 at 18:36
  • The option may show after similar to how PDFs are handled. But regardless you may look at a custom HTTP header to tell Safari that it isn't a text file. – Ryan Poolos Feb 12 '13 at 18:36
  • I've revised my question to reflect the current developments. As long as the file is binary I get the "open in myApp" prompt, but when the file is a text file, the browser will display its content and there doesn't seem to be a way to open in in "myApp" anymore. also it looks like custom HTTP headers get ignored on iOS (at least the ones about Content-Disposition) – EarlGrey Feb 12 '13 at 22:04
  • Is there any reason your file can't be an opaque binary format? – Ryan Poolos Feb 13 '13 at 13:20

1 Answers1

2

This has worked for me in /etc/apache2/httpd.conf

<IfModule headers_module>
  <FilesMatch ".custom$">
    Header Set Content-type application/myApp
    Header Set Pragma public
    Header Set Expires 0
    Header Set Cache-Control private
  </FilesMatch>
</IfModule>

The key was setting the Content-type, since Content-Disposition gets ignored in Safari on iOS. Credit goes to Aaron. (sorry I forgot your full name, since the other answer got deleted along with your comment). If you add your answer, I'll switch to it. Thank you.

EarlGrey
  • 2,514
  • 4
  • 34
  • 63