Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Facebook App browser - force link to open in Safari

Tags:

ios

facebook

The Facebook App has it's own browser (using the UIWebView for iOS apps) but it has a few limitations. We need certain links on our site to be sure to be viewed with Safari on iOS.

The FB app has an option to manually open links in Safari, but is there a way to do this automatically? Ie. some JS or special parameter in the a tag link to force open in Safari.

like image 786
James Reategui Avatar asked Jun 21 '13 19:06

James Reategui


2 Answers

well iOS uses something called an URL Scheme so you might be able to try to use that. It works with native code...

NSString *stringURL = @"http://fakewebsite.example.com/";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

not sure if it is possible to do something similar in javascript

like image 101
Ben Avatar answered Nov 19 '22 10:11

Ben


There might not be a way to automate this but you should be able to detect it and handle it more gracefully. Facebook adds some extras to the User agent string so you could sniff for some of the FB.. info bits:

Mozilla/5.0 (iPad; U; CPU iPhone OS 5_1_1 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.1.1;FBBV/4110.0;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/5.1.1;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US;FBSF/1.0]

There seems to be some people trying to figure out what they mean, but regardless they tell you that you're within that facebook web frame.

Sniffing (js or backend) for one of these would allow you to load the page differently or at least display an explanation and instructions to open it in safari. Still not automatic but you can at least detect the situation and have a documented manual solution.

like image 30
paaat Avatar answered Nov 19 '22 12:11

paaat