当用户按下邮件链接时,如何在iPhone中打开已安装的应用程序,如果没有安装,那么如何重定向到应用商店链接?
答案 0 :(得分:4)
将以下行添加到plist文件中:( DemoTest是我的自定义URL架构)
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>DemoTest</string>
<key>CFBundleURLSchemes</key>
<array>
<string>DemoTest</string>
</array>
</dict>
</array>
然后尝试从浏览器URL打开DemoTest://它将要求您打开已安装的应用程序。
HTML代码:
<html>
<body>
<script type="text/javascript">
window.onload = function() {
// Deep link to your app goes here
document.getElementById("l").src = "DemoTest://";
setTimeout(function() {
// Link to the App Store should go here -- only fires if deep link fails
window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
}, 500);
};
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
</body>
</html>