【问题标题】:How to implement deep linking in Windows Phone 8如何在 Windows Phone 8 中实现深度链接
【发布时间】:2015-11-06 18:27:30
【问题描述】:

我正在尝试使用 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 中,我已将协议声明为:

<Extensions>
  <Protocol Name="myapp" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>

我在私人服务器上托管了 html,但通过 Windows Phone 上的 Internet Explorer 导航到该页面并没有打开应用程序,而是只显示网页。我对深度链接很陌生。我做错了什么?

【问题讨论】:

  • @chris-w 它是 xaml ... WMAppManifest 是 xaml 文件
  • 不是XAML amigo,是XML,有很大区别。 :)

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


【解决方案1】:

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>

如果您不想自己实现它,那么您可以使用第 3 方提供商进行深度链接,例如Shortcut Media(免责声明:我目前在 Shortcut Media 工作)。

【讨论】:

  • 非常感谢。 AppLinks 文档没有说明向网站添加任何代码。我希望这可以像在 Android 和 iOS 中一样工作。有没有可能??我的意思是不向网站添加脚本!!
  • 您还需要为 Android 和 iOS 的网站添加代码(至少要支持带有自定义 URL 方案的深层链接)... AppLinks 只是一个协议,用于描述如何发布和导航深层链接,您必须自己进行实际实施或使用 3rd 方框架(请参阅applinks.org/documentation/#implementations)...
猜你喜欢
  • 2020-12-01
  • 1970-01-01
  • 2021-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多