[英]Link to open facebook app if app exists, else webpage
I'm looking for a solution to the following. 我正在寻找以下解决方案。 We're looking to send a html mailer out next week and currently having some issues.
我们希望下周发送html邮件,目前存在一些问题。 This is the first one we've tried to do like this, and the main difference is that it now contains buttons which link to our facebook.
这是我们尝试这样做的第一个,主要区别在于它现在包含链接到我们的Facebook的按钮。
The mailer is responsive and so we are looking for a solution which will open the desktop version of the site in browser, and when viewing from a mobile, check if the app is installed and open it, and if not open the link in the browser instead. 邮件程序响应迅速,因此我们正在寻找一种解决方案,该解决方案将在浏览器中打开网站的桌面版本,并且从移动设备查看时,请检查该应用程序是否已安装并打开,如果未在浏览器中打开链接代替。
Through extensive search online and Stack Overflow I've come to realise that there is a difference between how Android and iOS allow this. 通过广泛的在线搜索和Stack Overflow,我已经意识到Android和iOS允许这样做的方式有所不同。 See below the solutions I have tried so far:
请参阅下面我到目前为止尝试过的解决方案:
.mobile-link { display: none; } @media screen and (max-device-width: 767px) and (orientation: portrait) { .desktop-link { display: none; } .mobile-link { display: block; } } @media screen and (max-device-width: 1024px) and (orientation: landscape) { .desktop-link { display: none; } .mobile-link { display: block; } }
<a class='mobile-link' onclick=' setTimeout(function () { window.location = 'www.facebook.com/profileid'; }, 2500); window.location = 'fb://facewebmodal/=pagename';'> <img src='some.url' /> </a> <a class='desktop-link' href='www.facebook.com/profileid'> <img src='some.url' /> </a>
This is not working on iPhone although my previous attempt was (I changed it to make it work for Android, which still doesn't work). 尽管我以前的尝试是这样的,但这在iPhone上不起作用(我对其进行了更改以使其可在Android上使用,但仍然无法使用)。 In my previous attempt I had :
在之前的尝试中,我有:
<a class='mobile-link' onclick='
setTimeout(function () { window.location = 'www.facebook.com/profileid'; }, 2500);
window.location = 'fb://profile/id';'>
<img src='some.url' />
</a>
Which worked for iOS but not for Android. 适用于iOS,但不适用于Android。
From what I understand facebook seems to change how users can target the app in this manner regularly. 据我了解,facebook似乎改变了用户以这种方式定期定位应用程序的方式。
Can anyone provide me with the most recent way to target both the iOS and Android app in a link of this kind please? 有人可以通过这种链接向我提供针对iOS和Android应用程序的最新方法吗?
Here are the couple of links where you can find your suitable answer: 以下是几个链接,您可以在其中找到合适的答案:
First you need to check browser is in mobile device or in desktop then apply below link code as per your requirement. 首先,您需要检查浏览器是在移动设备中还是在台式机中,然后根据需要应用以下链接代码。 here is the browser detect link : - Detecting a mobile browser
这是浏览器检测链接:- 检测移动浏览器
1) http://findnerd.com/list/view/How-to-detect-if-an-app-is-installed-in-IOS-or-ANDROID-with-the-help-of-javascript-and-Deep-Linking/4287/ 1) http://findnerd.com/list/view/How-to-detect-if-an-app-is-installed-in-IOS-or-ANDROID-with-the-help-of-javascript-and-深度链接/ 4287 /
2) How to check if an app is installed from a web-page on an iPhone? 2) 如何检查是否通过iPhone上的网页安装了应用程序?
3) iPhone browser: Checking if iPhone app is installed from browser 3) iPhone浏览器:检查是否从浏览器安装了iPhone应用程序
Let me know if you still need anything else. 让我知道您是否还有其他需要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.