使用Facebook深度URL打开应用程序时,应用程序和网页会同时打开

编程入门 行业动态 更新时间:2024-10-28 06:28:45
本文介绍了使用Facebook深度URL打开应用程序时,应用程序和网页会同时打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将其用作网页中的链接.

I am using this as my link in webpage.

<a class="btn btn-lg btn-orange" role="button" onclick="myFunction()">like me</a>

这是我的脚本.

function myFunction() { $(function(){ window.location = "fb://profile/1456471431314551"; setTimeout(function () { window.location = "www.facebook/angelsatwork2015"; }, 25); }) }

当我在移动设备中打开时,浏览器的fb页面和fb应用程序都会打开.请提供帮助,以便在应用打开时不会重定向到fb浏览器页面. 同样,当我在台式机上使用此代码时,也会打开两个不同的浏览器页面.

When I open in mobile both the browser fb page and the fb app open. Please help so that if the app opens it does not redirect to fb browser page. Also when I use this code on desktop two different browser pages open.

推荐答案

这很可能是该代码的预期行为.

This is most likely the expected behavior for that code.

单击该按钮时,您正在做的是立即打开URL fb://profile/1456471431314551.假设这是iOS,这将导致系统显示警报,询问您是否要启动该应用.但是,从iOS 9.2开始,此警报为 non-blocking (无阻塞),这意味着其他代码将继续在后台执行.这就是为什么25毫秒后,您将URL www.facebook/angelsatwork2015作为常规网页打开的原因.

What you're doing when that button is clicked is immediately opening the URL fb://profile/1456471431314551. Assuming this is iOS, this causes the system to show an alert asking if you want the app to launch. However, as of iOS 9.2, this alert is non-blocking, which means other code continues to execute in the background. This is why, 25 milliseconds later, you're opening the URL www.facebook/angelsatwork2015 as a regular webpage.

不幸的是,在iOS 9.2+的世界中,没有很好的解决方案(感谢Apple ...).我们在 Branch.io 中所做的是通用链接的组合(在安装应用程序时会启动该应用程序...大多数时间)和重定向,例如针对通用链接无法正常工作的情况进行的重定向.我们根据设备UUID设置了跟踪Cookie,以了解何时可以安全地尝试启动该应用程序,但是实际上,这通常意味着,如果我们不确定,我们就必须重定向到App Store,以避免您的行为.遇到.

Unfortunately there is no good solution to this in the iOS 9.2+ world (thanks, Apple...). What we do at Branch.io is a combination of Universal Links (which launch the app when it is installed...most of the time) and redirections like the one you're trying for edge cases where Universal Links don't work. We set tracking cookies based on device UUID to know when we are safe to attempt launching the app, but in reality, this often means we have to redirect to the App Store if we aren't sure, just to avoid the behavior you're encountering.

更多推荐

使用Facebook深度URL打开应用程序时,应用程序和网页会同时打开

本文发布于:2023-11-27 04:57:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636696.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   深度   网页   Facebook   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!