从html链接重定向到IOS应用程序

时间:2013-12-10 06:46:42

标签: ios iphone app-store tracking

我是IOS开发的新手。我想知道有任何方法可以从正常的html链接(safari浏览器)重定向,例如<a href="my sdk link">click here to download the awesome app</a>到我的SDK(这里我想找出IDFA for用户跟踪)然后重定向到App Store中的应用下载页面。

2 个答案:

答案 0 :(得分:2)

使用Javascript可以解决您的问题。

<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 is here.

答案 1 :(得分:0)

添加SVWebViewController库,

在SVWebViewController.h中的#import,你想打开写代码打开

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