问题
my webpage has links to download Passbook .pkpass files. This works fine in Safari for iOS since Apple's browser supports the mime type: application.com/vnd.apple.pkpass
Facebook's iOS browser (as well as others) does not (yet) support this mime type. Therefore, if a user follows a link to my site from within Facebook, they can't download my Passbook files. However, if they click on 'Open in Safari' then they can download the file.
How can I code my webpage such that clicking on a link will force open Safari on iOS?
Andrew
回答1:
These headers should be helpful to what you're doing.
Content-Type "application/force-download"
Content-Description "File Transfer"
Content-Disposition attachment
ForceType "application/octet-stream"
I suggest you try to set them in your .htaccess or httpd.conf file with the following code:
<FilesMatch "\.(pkpass)$">
Header set Content-Type "application/force-download"
Header set Content-Description "File Transfer"
Header set Content-Disposition attachment
Header set ForceType "application/octet-stream"
</FilesMatch>
It's a little overkill, but will ensure the download is forced across all browsers. Change the pkpass to anything else to force the download of any other file type.
回答2:
I didn't manage to find a way to do this yet. Somehow, forced pkpass downloads won't work in the Facebook mobile browser.
The best way is to guide the user to open the page in Safari.
来源:https://stackoverflow.com/questions/14537235/how-to-force-links-to-open-in-ios-safari