如何 "listen" 用于 customtabsintent url?

How to "listen" for customtabsintent url?

我目前正在使用 xamarin.forms 和 xamarin.auth 对用户进行身份验证。 我可以使用 CustomTabsIntent 启动 URL,但是我无法弄清楚如何 "listen" 用于重定向 URL。用户登录后,它只是位于自定义选项卡

中的重定向URL页面上

当 customtabsintent 到达 redirectUrl 时,如何切换回我的 android 应用程序?

@SchwartzBrian 你需要一个叫做 App (Deep) linking 的概念,基本上

  • 使用与 Activity 关联的 IntentFilter 注册自定义方案(在 Xamarin.Android IntentFilter 是 Activity 上的属性)
  • 登录浏览器 (CustomTabs) 后将通知 OS 存在浏览器无法处理的自定义方案,并且 OS 将查找可以处理的已注册方案和包(以及关联的活动)这个自定义方案。如果 Activity 是 'found' OS 将启动它并将 URL 从浏览器传递到 Activity.OnCreate() 方法。

参见: https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences/blob/master/Xamarin.Forms/Evolve16Labs/Droid/Xamarin.Auth/ActivityCustomUrlSchemeInterceptor.cs#L19-L48