Chrome 自定义选项卡中是否有任何等效的 webViewClient

问题描述

我正在开发一款通过 Salesforce 实现 Google 登录的应用。 IE。 Salesforce IDP 负责通过 Google 对用户进行身份验证,并通过深层链接用户重定向到应用的主屏幕。

现在,由于 Google 不再允许应用程序在 webview 上打开 Google 登录页面,因此我不得不使用 Chrome 自定义选项卡或浏览器。身份验证后,我需要撤销将 OAuth 推送到应用程序的回调。目前它是通过 webview 的 webViewClient 完成的,其中 onShouldOverrideUrlLoading 被覆盖。是否也可以在 Chrome 自定义标签或浏览器中进行?

更具体地说,我使用网络视图的现有代码如下:

    override fun loadWebView(callback: LoginWebViewClient) {
        login_web_view?.webViewClient = callback
        login_web_view?.webChromeClient = object : WebChromeClient() {
            override fun onProgressChanged(view: WebView,newProgress: Int) {
                super.onProgressChanged(view,newProgress)
                if (!isLoginProcessstarted) {
                    showProgress(newProgress != 100)
                }
            }
        }
        loadLoginoAuth()
    }

我想知道如何为自定义选项卡或浏览器模拟第二行?

解决方法

自定义标签在 CustomTabsCallback (demo) 中有导航回调,但只为 NAVIGATION_STARTEDNAVIGATION_FINISHED 提供信号。后者可以用于您的目标。