Search code examples
javascriptios8mobile-safari

ios8 doesn't work open url scheme from safari


Hi this code works ios7 safari. but ios8 is not working.

setTimeout(function(){ if (+new Date - ca < 1000) {//open appstore }}, 500) ;

location.href = "myapp://"

i tryed iframe, document.location.href, window.location, window.open.....

give me a solution please!

how to change this source?


Solution

  • I too experienced the same issue you're seeing. It seems as if safari ios8 does not load the app store if the app store url scheme is opened within an iframe. Oddly, it will open your app (if your app is installed) regardless of being called within an iframe.

    I solved this issue by targeting the app store url to the parent window.

    This is the javascript I have in my iframe:

    var appStoreUrl = 'itms-apps://itunes.apple.com/gb/app/...';
    var loadedAt = +new Date;
    setTimeout(function() {
      if (+new Date - loadedAt < 2000) {
        window.parent.location.href = appStoreUrl;
      }
    }, 100);
    
    window.location.href = 'myapp://...';