Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force iOS Facebook App to open feed links in Browser not in WebView

(Before downvoting/flagging please note that there are already similar questions but none of them do work with plain javascript)

Whenever a Link on the Facebook-Feed is clicked on an iOS device (only via facebook app) it will open in a WebView and not in a new browser window (like it is on android).

When this happens, the web application that is about to be opened breaks, so I need to trick iOS somehow and force it to open the link in the users standard browser (where the web application works flawlessly).

If that's only possible when a button is klicked it would also be no problem. But from what I have tried everything opened in the WebView and I just could not get it managed to open it in the browser.

I've seen a couple of ObjectiveC solutions which I cannot of course make use of in a web application. So I'd like to stick to JS/HTML (or PHP but I don't think it will be much of a help)

What does not work:

<a href="http://google.com" target="_blank">My Link Text</a>

A normal link with the target attribute will not do the trick. The link will instead open within the WebView.

window.open('http://google.com');

window.open won't work neither (of course I've attached it to an event handler). It seems that the webview will not respond to window.open() anyways.

So anyone here who has a solution? I hope that's not some weird iOS guidline.

like image 970
thpl Avatar asked Apr 03 '14 17:04

thpl


People also ask

How do I force the Facebook app to use an external browser to view links?

In the Facebook app, tap the three-line menu icon at the top right corner, then scroll down to Settings & Privacy -> Settings. Scroll down to Media. At the very bottom, you should see “Links open externally”. Check this box to enable it.

Does Facebook use Webview?

Later today it's releasing Facebook for Android 2.0, which replaces the hybrid native/webview code with an all-native infrastructure to answer years of complaints by making the app much faster.


1 Answers

This behaviour is controlled by the Facebook app. There is an explicit call on iOS to open a URL with the system tool (such as Safari for regular web addresses). If the Facebook app is opening URLs via its in-built web view then there isn't much you can do

like image 147
Paulw11 Avatar answered Oct 19 '22 10:10

Paulw11