我是用url scheme唤醒app。
需求是如果app存在的话打开app,不存在的话,ios跳转到appstore,安卓跳转到google play。
var nowTime = new Date().valueOf();
setTimeout(function() {
var launchTime = new Date().valueOf() - nowTime;
if (launchTime < 400) {
if (checkIos()) {
window.location.href = "https://itunes.apple.com/us/app/xxx/idxxx?mt=8";
} else {
window.location.href = "https://play.google.com/store/apps/details?id=xxx";
}
}
}, 300);
window.location.href = "url://url scheme";
但是有个bug是,在safari中,如果app在手机中不存在(还没有下载),点击按钮后会弹出一个“网页无效”,然后才是弹出“是否前往app store”。
通过百度,尝试使用iframe 来请求url scheme,安卓下是ok的,但是在safari中不起作用。貌似iframe在safari已经被屏蔽的样子,求大神还有没有好的方法能解决我的问题,跪谢。
上午刚回答一个,不知道行不行。。