2013-12-10 88 views
4

我是IOS開發新手。我想知道有什麼方法可以從正常的html鏈接(Safari瀏覽器)重定向,例如<a href="my sdk link">click here to download the awesome app</a>到我的SDK(這裏我想找出用戶的IDFA跟蹤),然後重定向到App Store中的我的應用下載頁面。從html鏈接重定向到IOS應用程序

回答

0

要打開寫代碼來打開

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

使用JavaScript就可以解決你的問題添加SVWebViewController庫,

#進口的SVWebViewController.h。

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

+0

感謝。這真有趣。我會試試這個。 – Inaccessible

+0

安裝應用程序之前可以獲得idfa值嗎? – Inaccessible

相關問題