0

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

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

4

1 回答 1

1

@SchwartzBrian您基本上需要称为App(Deep)链接的概念

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

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

于 2017-05-17T11:04:23.090 回答