Faysal
Faysal

Reputation: 101

Is there any equivalent of webViewClient in Chrome Custom Tab

I am working on an app which implements Google Login through Salesforce. I.e. Salesforce IDP takes care of authenticating user with Google and redirects the user to the home screen of the app through deeplink.

Now as Google does not more allow apps to open Google login page on webview I am having to use the Chrome Custom tab or browser. After authentication I need to revoke a callback that will push the OAuth to app. Currently it is done through the webview`s webViewClient, where the onShouldOverrideUrlLoading is overridden. Is it possible to do in Chrome Custom Tab or Browser as well?

To be more specific on my question, my existing code using web view is as following:

    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()
    }

I want to know how can emulate the second line for a custom tab or browser?

Upvotes: 4

Views: 1374

Answers (1)

andreban
andreban

Reputation: 4976

Custom Tabs has navigation callbacks in CustomTabsCallback (demo), but only provides signals for NAVIGATION_STARTED and NAVIGATION_FINISHED. The latter could possible be used for your goal.

Upvotes: 1

Related Questions