android - 从重定向而不是链接打开 android 应用程序
问题描述
我在尝试深层链接和打开我的应用时遇到问题。我有以下代码,可以让我确定我是否有 ios 用户或 android。如果它是 android,那么我想重定向用户以打开他们的应用程序(如果已安装)。
问题是重定向到company://open.me/
没有打开应用程序
如果我创建一个手动链接,例如
<a href="company://open.me/">Open Me</a>
这工作正常并打开我的应用程序。
有什么帮助吗?
<script>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("company://");
setTimeout(function() {
if (!document.webkitHidden) {
location.replace("https://www.company.com");
}
}, 25);
} else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
window.location = "company://open.me/";
} else {
location.replace("https://www.company.com");
}
</script>
显现
<intent-filter>
<data android:scheme="company" android:host="open.me" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
解决方案
推荐阅读
- javascript - 如何在 Jquery 中创建窗帘淡出效果?
- python - 限制 celery 中同时执行的特定任务的数量
- reactjs - POST oauth 令牌最初发送没有数据/标头的 OPTIONS 请求,并以 401 失败
- javascript - 如果我需要稍后定义它,我该如何使用它?
- c# - 如何在 ASP.NET Core 视图中使用 DefineSection(...)?
- c++ - 结构中未指定数量的变量
- php - 在 WooCommerce,我希望将零价格的产品移至列表底部
- python - 有条件的排列
- julia - 获取数组类型
- python - 基于字典在循环中定义变量