关于h5唤醒app

我是用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已经被屏蔽的样子,求大神还有没有好的方法能解决我的问题,跪谢。

阅读 4.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题