🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
安卓 | IOS系统 applinks 声明与app的关联文件 安卓 https://域名/.well-known/assetlinks.json IOS https://域名/.well-known/apple-app-site-association ${uri} 参数:例 name=打开app&age=23 xx.xx.xx 表示安卓包名称 || scheme名称 打开ios app方式: 就一种 https://applinks绑定的域名${uri} 打开安卓app方式: * intent://你的域名${uri}#Intent;scheme=https;end 这种方式如果没有安装app会访问https://你的域名${uri} * xx.xx.xx://xx${uri} 华为手机基本上都支持这种打开方式 * intent://xx${uri}#Intent;scheme=xx.xx.xx;end 测试有限,只要是Oppo手机就用这种方式打开app * 配置applinks 仅支持6.0以上系统,如何配置叫上你们的安卓小哥哥|小姐姐《进行深入》的《探讨》 ``` /** * 打开app * @param uri */ export function OpenApp(uri: string) { if (Ios) { // 检测是否为ios window.location.href = `https://xxxx.com/index.html${uri}`; return; } let isOpenTime: boolean = false; // 是否创建定时任务 let url: string = `intent://域名/index.html${uri}#Intent;scheme=https;end`; if (Huawei || Huawei_LLD) { url =`xx.xx.xx://xx${uri}`; // 所有安卓手机默认使用该地址 isOpenTime = true; } if (Oppo) { url = `intent://xx${uri}#Intent;scheme=xx.xx.xx;end`; isOpenTime = true; } let checkTimeout: any = ''; // 检测是否已经离开了当前页面 document.addEventListener("visibilitychange", function(){ if (document.hidden && checkTimeout !== '') { // 如果离开当前页面,清除定时任务 clearTimeout(checkTimeout); } }); window.location.href = url; if (isOpenTime) { // 做这一步的原因:有些安卓手机 提示是否进入app,如果3秒后不做任何操作执行以下操作 checkTimeout = setTimeout(() => { // 进入下载页面 | 直接下载 根据业务需求进行开发 window.location.href = `https://xxxx.com/index.html${uri}`; }, 3000); } } ```