I'm running into an issue where entering a bank account triggers an Authenticate pop-up for users inside a WebView. This pop-up is controlled via Stripe.js. Currently, the "Auth" button is shown but nothing happens when the user clicks on it. I can see that the onPageStarted
is triggered via the WebViewClient with the url. The user receives an OTP via SMS, but because nothing happens they have nowhere to enter it.
On Chrome, the Auth button opens a new tab where it loads a page for the user to enter the OTP. Why is this new page not loading given the code below? Am I adding the new WebView correctly? I don't see any documentation on this. This is the only example I've found https://stackoverflow.com/a/27010225/1649472
webView.settings.setSupportZoom(true)
webView.settings.javaScriptEnabled = true
webView.settings.offscreenPreRaster = true
webView.settings.setSupportMultipleWindows(true)
webView.settings.javaScriptCanOpenWindowsAutomatically = true
webView.addView(newWebView)
webView.webChromeClient = object : WebChromeClient() {
override fun onCreateWindow(view: WebView?, isDialog: Boolean, isUserGesture: Boolean, resultMsg: Message?): Boolean {
val newWebView = WebView(requireActivity())
newWebView.settings.setSupportZoom(true)
newWebView.settings.loadWithOverviewMode = true
newWebView.settings.javaScriptEnabled = true
newWebView.settings.offscreenPreRaster = true
newWebView.settings.setSupportMultipleWindows(true)
newWebView.settings.javaScriptCanOpenWindowsAutomatically = true
newWebView.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
// Starts loading
super.onPageStarted(view, url, favicon)
}
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
// Never called
val newUrl = request?.url?.toString()
val browserIntent = Intent(Intent.ACTION_VIEW)
browserIntent.data = Uri.parse(newUrl)
startActivity(browserIntent)
return true
}
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler?, error: SslError?) {
// Never called
handler?.proceed()
}
}
val transport = resultMsg?.obj as? WebView.WebViewTransport
transport?.webView = newWebView
resultMsg?.sendToTarget()
return true
}
}