Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open Facebook app from url only if installed

I would like to know how to open up a url link from my website in the facebook and twitter app only if it is installed on the device, if not I would like the page to be opened in the browser.

Currently I am using the following links:

fb://profile/fbID
twitter://user?screen_name=username

Currently it works fine if the app is installed but the link fails if the app isn't installed, further to this the twitter link fails completely if you try to open it in a desktop browser.

Would anyone know how I go about this?

Yes I know there are similar questions but none have been answered so I thought I'd try this, cheers.

like image 781
tezzataz Avatar asked May 26 '13 16:05

tezzataz


1 Answers

You can try redirecting the phone to opening the app, and if nothing happens, redirect it to the web page you want.

setTimeout(function () { window.location = "https://itunes.apple.com/appdir"; }, 25);
window.location = "appname://";

If the second line of code works, then the first won't be executed.

like image 101
scarecrow850 Avatar answered Sep 17 '22 10:09

scarecrow850