c# - 如何在 Windows Phone 8 中实现深度链接

标签 c# html xml windows-phone-8 deep-linking

我正在尝试使用 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/

相关文章:

c# - Xamarin 表格 : Android: Toast Notifications Clicked

javascript - 使 li 项目框按顺序弹出 jQuery

html - Bootstrap 3 : Missing gutters

javascript - 更改 Bing map 元素中的 CSS?

android - CSS 样式的自定义字体字样

java - 为什么我的页面在 Android 中无法转到下一个页面

c# - 在什么情况下 Text 可能与 ValueText 不同

c# - 如何使用 dapper .net 进行多次插入和更新?

c# - 元素(名称)返回 null

xml - Golang Google 警报 XML 解析