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

后端 未结 10 980
忘了有多久
忘了有多久 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:10

    The date solution is much better than others, I had to increment the time on 50 like that this is a Tweeter example:

    //on click or your event handler..
    var twMessage = "Your Message to share";
    var now = new Date().valueOf();
    setTimeout(function () {
       if (new Date().valueOf() - now > 100) return;
       var twitterUrl = "https://twitter.com/share?text="+twMessage;
       window.open(twitterUrl, '_blank');
    }, 50);
    window.location = "twitter://post?message="+twMessage;
    

    the only problem on Mobile IOS Safari is when you don't have the app installed on device, and so Safari show an alert that autodismiss when the new url is opened, anyway is a good solution for now!

提交回复
热议问题