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
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.
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.
Related
I tried pdf, txt and png file url, only pdf url can't be open with browser if click the url, but trigger download.
I google this but only got how to fix, like instead with google doc or use pdf.js, or other html code.
What is the reason? the website ? Forgive me that i have no idea of website architecture.
When you get a file from a website, it has a content type sent along with it. Depending on the content type, the browser may choose to display it. For example, content type "application/pdf" might be shown in a browser, but "application/octet-stream" will be downloaded.
The raw URL on GitHub has content type "application/octet-stream" (a binary file) so that it will be downloaded.
The only way around this, since you can't change GitHub's code that sets the content type, is to get the data from JavaScript and parse it there -- by using pdf.js or something similar.
I have created a codeigniter application with a file upload feature. This is loaded as my Facebook app in a Canvas page. I have set my allowed types as png,jpg, mp4.
When tested on localhost this works fine and uploads well.
However, when uploaded on my server and installed as my canvas app, when I access my page via apps.facebook.com/myapp, the images are uploaded fine, BUT, when I try to upload a mp4 file, thatwas successfully uploaded on localhost version, it returns the upload error "The filetype you are attempting to upload is not allowed.".
But I have set it as an allowed type.
I tried uploading via the canvas url (www.myapps.com/apps) rather than the canvas page (apps.facebook.com/myapp), but it gives the same problem, it says the type is not allowed.
I thought it might be server not configured so I add AddType video/mp4 .mp4 to the server's and app folder's .htaccess.
Also I made sure that mp4 is added in the mime.php in my codeigniter app.
Just not sure what to do again. It keeps saying it's not allowed, but it is.
Any help would be great. How do I fix this?
Try adding the both mime types in the list in the config folder for codeigniter. Like this.
'mp4' => array('video/mp4', 'application/octet-stream')
I have exported an event in the .ics format from iCal and linked to the file from an event site i am creating.
When i navigate the link in Chrome on my MacBook it correctly opens iCal and subscribes to the event.
However when i navigate to the same page in iPhone Safari and navigate the link it retrieves an error where it says it cannot subscribe to the calendar.
Am unsure as to why it is working in one and not the other:
http://tfma2012.valtechdigital.co.uk/
The calendar location is as follows:
webcal://tfma2012.valtechdigital.co.uk/calendar/TFMA.ics
Instead of using "webcal://" as the address, simply use "http://"; it worked perfectly for me on both my Mac and iPhone when I tried that.
Just put this code and check
[[UIApplication sharedApplication]openUrl:[NSUrl urlWithString:[NSString stringWithFormat:#"webcal://tfma2012.valtechdigital.co.uk/calendar/TFMA.ics"];
If you use http:// so usage of Content-Type: text/calendar HTTP header considered (Not tested) personally You can use same page name with text/html header for desktop browsers to show "how to" manual.
If you use webcal:// it is also well supported on iOS, the header must be Content-Type: text/calendar (Tested, works on iOS 13)
You can go even further and show url like webcal://example.com/schedule/?staff_id=1245 encoded in QR code. On camera mode iOS device will suggest you to subscribe to the iCalendar feed.
Most likely the link is just outdated. Open your calendar, turn off the public link and turn it on, the new address will work 😉
Through Document Interaction, my iOS app registers itself as an editor of .sgf and .ugi files. So I can open such files from - let's say - attachements in Mail.
However, when trying the same from Safari, I get inconsistent behavior. I try to open .sgf documents that are available via HTTP into my App.
Some http links trigger the gray box with "Open in..." button... Good.
http://gtl.xmp.net/reviews/data/82/8201-DavidB-mukai-jettero.sgf
Other links open as a text file in Safari... Unwanted.
http://learngo.world-go.org/golibrary/samplelessons/studygroup30k/2004-06-11_20-30k.sgf
Is there a way to get the "open in..." button on all?
After some research I got most of the answer from this page:
https://developer.mozilla.org/en/Properly_Configuring_Server_MIME_Types
And this web tool:
http://www.rexswain.com/httpview.html
SafariMobile looks at the MIME-type that is returned by the web server to determine what to do with the link (view within Safari or offer 'Open In...'.
Supported types like 'text/plain', 'text/html', 'image/gif' are all displayed within Safari. Whereas an unsupported type like 'application/zip' will trigger the 'Open in...' interface.
But Safari will even try to display a link of the type 'application/octet-stream', which is the mime-type typically used for unknown binary formats. I suppose Apple did this to overcome web servers that fail to provide the proper mime-type.
Supplying the type along within the HTML code is ignored by Safari.
<a href='file.sgf' type='application/x-go-sgf'>
The only (I think) solution is to change the configuration of the web server.
I would like to get a glimpse of web-sites created for iPhone devices. In order to be able to view those sites I have to modify the User-agent header in the HTTP request that my browser sends. That way I can trick the web-server into believing that my browser is an iPhone browser, and then the web-server would send my the iPhone version of the web-site.
So, how can I modify the User-agent header that my browser sends in each HTTP request.
Maybe there is an Firefox plug-in that allows modifying request headers?
Also, I think I heard that Safari allows that somehow....
You can try the user-agent switcher plugin.
Yeah you can do this with Modify Headers add-on for Firefox.
First, there's the following plugin: https://addons.mozilla.org/en-US/firefox/addon/59/
Also, there's Firefox configuration: type "about:config" as URL in Firefox, find general.useragent.* properties there.
You don't need a browser add-on in order to add a custom User-Agent string in your HTTP header. Chrome has added this feature to developer tools.
Open the developer tools and click on the Toggle Device Toolbar option or press cmd+shift+M to open it. You can select a device user agent from the presets or you can also define a custom device like mentioned in the below screenshot.