how to open Facebook app from url only if installed

18,001

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.

Share:
18,001
tezzataz
Author by

tezzataz

Updated on June 05, 2022

Comments

  • tezzataz
    tezzataz about 2 years

    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.