How to check if an app is installed from a web-page on an iPhone?

后端 未结 10 1031
忘了有多久
忘了有多久 2020-11-22 09:57

I want to create a web-page, a page that will redirect an iPhone to the app-store if the iPhone does not have the application installed, but if the iPhone has the app instal

10条回答
  •  半阙折子戏
    2020-11-22 10:21

    To further the accepted answer, you sometimes need to add extra code to handle people returning the browser after launching the app- that setTimeout function will run whenever they do. So, I do something like this:

    var now = new Date().valueOf();
    setTimeout(function () {
        if (new Date().valueOf() - now > 100) return;
        window.location = "https://itunes.apple.com/appdir";
    }, 25);
    window.location = "appname://";
    

    That way, if there has been a freeze in code execution (i.e., app switching), it won't run.

提交回复
热议问题