Facebook的URL方案在移动网站上,打开应用程序如果安装,否则转到网页 [英] Facebook URL schemes on a mobile website, open app if its installed, otherwise go to the webpage

查看:111
本文介绍了Facebook的URL方案在移动网站上,打开应用程序如果安装,否则转到网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个混合的桌面/移动网站,它们共享相同的页面,也就是说我没有两个桌面和移动的单独的网址。如果可能,我正在尝试在Facebook的应用程序中打开Facebook链接,否则转到常规URL。基本上,如果没有安装移动应用,或者如果用户在桌面上,请访问https:https: ://www.facebook.com/pages/ [pageid]



如果安装了移动应用,那么请到这里:



fb:// page / [pageid]

解决方案

一个简单的方法就是CSS Media Queries。 >

显示小型设备宽度的fb:/​​/链接。以及更大屏幕尺寸的常规http://链接。



编辑

 < a href =https://facebook.com/pageclass =large-screen> Clicky< / a> 
< a href =fb:// page / mypageclass =small-screen> Clicky< / a>

然后使用CSS Media查询根据屏幕大小隐藏其中一个链接。



更新



而不是使用CSS,可以使用javascript创建更令人满意的用户体验尝试在超时X秒后打开HTTP URL后直接打开深层链接URL。

  setTimeout(function(){ window.location =https://www.facebook.com;},25); 
window.location =fb://;

HTTP URL将始终加载,但在深层链接不可用的情况下,尝试打开一个人会默默地失败,回到网络版本。



资料来源: https://www.quora.com/How-does-Bitlys-Deep-Linking-detect- if-the-user-already-has-the-app-installed


I am creating a hybrid desktop/mobile website that all share the same pages, aka I do not have two separate URLs for desktop and mobile. I am trying to get Facebook links to open in the native Facebook app, if possible, otherwise go to the regular URL. Is there something out there in the Facebook schemes that handles that automatically?

Basically, if mobile app is not installed or if the user is on a desktop, go here: https://www.facebook.com/pages/[pageid]

If mobile app is installed, then go here:

fb://page/[pageid]

解决方案

A Simple way would be CSS Media Queries.

Show the fb:// link for small device widths. and a regular http:// link for larger screen sizes.

EDIT

<a href="https://facebook.com/page" class="large-screen">Clicky</a>
<a href="fb://page/mypage" class="small-screen">Clicky</a>

Then using CSS Media queries hide one of the links depending on the size of the screen.

UPDATE

Instead of using CSS a more satisfying user experience can be created with javascript by attempting to open the deep link URL directly after opening the HTTP URL after X seconds in a timeout.

setTimeout(function () { window.location = "https://www.facebook.com"; }, 25);
window.location = "fb://";

The HTTP URL will always load, but in the case that deep links are not available, attempting to open one will silently fail, falling back to the web version.

Source: https://www.quora.com/How-does-Bitlys-Deep-Linking-detect-if-the-user-already-has-the-app-installed

这篇关于Facebook的URL方案在移动网站上,打开应用程序如果安装,否则转到网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆