我正在尝试使用 myapp://moniker 实现深度链接。出于测试目的,我有一个包含以下元的 HTML 页面:
<html><head>
<meta property="al:windows_phone:app_id_here" content="12345" />
<meta property="al:windows_phone:url" content="myapp://products/?id=widget" />
<meta property="al:windows_phone:myapp" content="Example Store" />
<title></title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
在 WMAppManifest 中,我已将协议(protocol)声明为:
<Extensions>
<Protocol Name="myapp" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>
我已将 html 托管在私有(private)服务器上,但在 Windows Phone 上通过 Internet Explorer 导航到该页面不会打开该应用程序,而只会显示该网页。我对深度链接很陌生。我做错了什么?
最佳答案
AppLinks 元标记只会将您的深层链接宣传给抓取工具/机器人(这样 Google 就知道您的网站有相应的应用程序和深层链接)。
要实现实际的深层链接,您必须向您的网站添加一些代码。以下是一个非常简单的示例:
<script>
// when the page is loaded...
window.onload = function() {
// and viewed on a Windows Phone...
if (navigator.userAgent.match(/Windows Phone/)) {
// then try to open the deep link
window.location.replace('myapp://products/?id=widget');
// if it didn't work after half a second, then redirect the
// user to the app store where he can download the app
setTimeout(function() {
window.location.replace('http://www.windowsphone.com/s?appid=12345');
}, 500);
}
}
</script>
如果您不想自己实现它,那么您可以使用第三方提供程序进行深度链接,例如Shortcut Media (免责声明:我目前在 Shortcut Media 工作)。
关于c# - 如何在 Windows Phone 8 中实现深度链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33351820/