如何在Xamarin forms中实现Deeplink(通用链接)?包括Android和iOS。

4

各位,我需要逐步实现Applink(通用链接),包括android和iOS,请帮忙完成这个任务。我在我的android项目中尝试了下面的代码:

我按照以下URL编写了此代码https://devblogs.microsoft.com/xamarin/connect-with-your-users-with-google-search-and-app-indexing/

请注意,我不需要索引概念,只想从单击任何URL打开应用程序。

  1. 首先,我安装了Xamarin.Forms.AppLinks NuGet

  2. 以下是MainActivity的代码

[IntentFilter(new[] { Android.Content.Intent.ActionView },
        Categories = new[]
        {
            Android.Content.Intent.CategoryDefault,
            Android.Content.Intent.CategoryBrowsable
        },
        DataScheme = "http",
        DataPathPrefix = "/",
        DataHost = "test.com")]
  1. 在OnCreate方法中编写以下代码:
  AndroidAppLinks.Init(this);
  1. 我尝试从深度链接测试器中调用deeplink URL“test://DeeplinkingSample”

提示没有找到处理该意图的活动。

1个回答

1

4. 然后我尝试从Deep Link Tester调用deeplink URL“test://DeeplinkingSample”

它显示没有找到处理意图的活动

您正在尝试调用URL test://DeeplinkSample,该URL具有以下部分:

  • 方案是test
  • 主机名为DeeplinkSample
  • 没有数据路径

但是,您没有为该URL注册您的活动,而是为方案http、主机test.com和数据路径前缀/(即可能以/开头的所有数据路径)注册。因此,当您尝试打开时,应用程序应该打开。

http://test.com/...

很棒,Paul Kertscher,在 Deeplink tester link 上运行良好,但是使用类似 window.location.href= link 的 html 导航同样的 URL 时不起作用,我该怎么办? - SheikMydeenMuthu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接