如何安装时只能从网址打开Facebook应用程序

问题描述:

如果我不想在浏览器中打开该页面,我想知道如何在Facebook和twitter应用程序中打开我的网站的URL链接。

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.

目前我使用以下链接:

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

目前,已安装但链接失败,如果该应用程序未安装,进一步如此,如果您尝试在桌面浏览器中打开它,这个twitter链接将完全失败。

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.

知道我该怎么做?

是的,我知道有类似的问题,但没有一个回答,所以我以为我会尝试这个,欢呼。

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

您可以尝试将手机重定向到打开应用程序,如果没有发生任何事情,请将其重定向到所需的网页。

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.