在使用uniapp开发APP项目时,华为市场上线APP会被打回来:您的应用内容存在点击跳转至第三方应用市场或游戏中心下载渠道的问题,不符合华为应用市场审核标准。
华为审核指南4.6
因此可以考虑下面的处理方式,通过拦截webview页面的url实现:
onReady(() => {nextTick(() => {plusReady();});});const plusReady = () => {let pages = getCurrentPages();let page = pages[pages.length - 1];let currentWebview = page.$getAppWebview();let t: any = setTimeout(() => {// 加个延时器,确保能够拿到currentWebview.children()[0]clearTimeout(t);t = null;// 获取webview实例const wv = currentWebview.children()[0];// 除myweb.cn以外的页面跳转都将被拦截// 如需全部拦截:wv.overrideUrlLoading({ mode: 'reject' }, (e) => {}wv.overrideUrlLoading({ mode: 'allow', match: '.*.myweb.cn/.*' }, (e) => {uni.showModal({title: '提示',content: '尊敬的用户,您即将打开手机浏览器跳转页面,可能会存在安全风险,请谨慎操作。确定继续吗?',showCancel: true,success: ({ confirm }) => {if (confirm) {plus.runtime.openURL(e.url); // 使用外部浏览器打开,规避风险,跳出去了你想干啥和我APP没关系~~~~}}});});}, 500);};