Redirect from html link to iOS app

I am new to iOS development. I want to know that there is a way to redirect from a regular html link (Safari browser), for example <a href="my sdk link">click here to download the awesome app</a>, to mine SDK(here I want to learn IDFA for tracking users) and then redirect the application download page to the App Store.

+4
source share
2 answers

Using Javascript, you can solve your problem.

<html>
  <head>
    <meta name="viewport" content="width=device-width" />
  </head>
  <body>

    <h2><a id="applink1" href="fb://profile/116201417">open facebook with fallback to appstore</a></h2>
    <h2><a id="applink2" href="unknown://nowhere">open unknown with fallback to appstore</a></h2>
    <p><i>Only works on iPhone!</i></p>    

  <script type="text/javascript">

// To avoid the "protocol not supported" alert, fail must open another app.
var appstorefail = "itms://itunes.apple.com/us/app/facebook/id284882215?mt=8&uo=6";

function applink(fail){
    return function(){
        var clickedAt = +new Date;
        // During tests on 3g/3gs this timeout fires immediately if less than 500ms.
        setTimeout(function(){
            // To avoid failing on return to MobileSafari, ensure freshness!
            if (+new Date - clickedAt < 2000){
                window.location = fail;
            }
        }, 500);    
    };
}

document.getElementById("applink1").onclick = applink(appstorefail);
document.getElementById("applink2").onclick = applink(appstorefail);

</script>
</body>
</html>

Live demo here.

+2
source

Add the SVWebViewController library,

#import in SVWebViewController.h where you want to open the post code to open

SVWebViewController *webViewController = [[SVWebViewController alloc] initWithAddress:@"http://www.google.com"];
[self.navigationController pushViewController:webViewController animated:YES];
0
source

All Articles