如何实现在Windows Phone 8的深度链接 [英] How to implement deep linking in Windows Phone 8
问题描述
我想实现的myapp使用深层链接://绰号。出于测试目的,我有以下元的HTML页面:
I am trying to implement deep linking using myapp:// moniker. For testing purpose I have an HTML page with the following meta:
<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,我已宣布该协议为:
And in WMAppManifest, I have declared the protocol as:
<Extensions>
<Protocol Name="myapp" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>
我主持的HTML专用服务器上,但通过Internet Explorer在Windows Phone没有按导航页面'T打开应用程序,相反,它只是显示的网页。我是很新的深度链接。我在做什么错了?
I have hosted the html on a private server but navigating to the page through Internet Explorer on Windows Phone doesn't open the app, instead, it just shows the webpage. I am very new to deep linking. What am I doing wrong?
推荐答案
meta标签只做宣传您的抓取工具/漫游深层链接(这样如谷歌的AppLinks知道你的网站有一个对应的应用程序和深层链接)。
The AppLinks meta tags do only advertise your deep links to crawlers/bots (so that e.g. Google knows that your website has a corresponding app and deep links).
要实现实际的深度链接,你必须添加一些代码到您的网站。下面是一个非常准系统例如:
To implement the actual deep linking you have to add some code to your website. The following is a very barebones example:
<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>
如果你不想自己去实现它,那么你可以使用深层链接第三方提供商,例如: 快捷媒体(声明:我目前快捷键媒体工作)。
If you do not want to implement it by yourself then you can use a 3rd party provider for deep links, e.g. Shortcut Media (Disclaimer: I currently work at Shortcut Media).
这篇关于如何实现在Windows Phone 8的深度链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!