【问题标题】:How to "listen" for customtabsintent url?如何“监听”customtabsintent url?
【发布时间】:2017-05-16 19:42:02
【问题描述】:

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

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

【问题讨论】:

    标签: android xamarin.forms android-authenticator


    【解决方案1】:

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

    • 向与 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

    【讨论】:

    猜你喜欢
    • 2011-03-10
    • 2020-08-06
    • 2021-05-23
    • 1970-01-01
    • 2010-10-23
    • 2021-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多