You need to update WebViewClient interface to handle SSLError.
Otherwise, you will get Alert from google play store after publishing the app. You can try this bunch of code to handle
bkashWebView.webViewClient = object : WebViewClient() {
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler, error: SslError?) {
val builder = AlertDialog.Builder(context!!)
val message = when (error?.primaryError) {
SSL_UNTRUSTED -> "The certificate authority is not trusted."
SSL_EXPIRED -> "The certificate has expired."
SSL_IDMISMATCH -> "The certificate Hostname mismatch."
SSL_NOTYETVALID -> "The certificate is not yet valid."
SSL_DATE_INVALID -> "The date of the certificate is invalid"
else -> "A generic error occurred"
}
builder.setTitle("SSL Certificate Error")
builder.setMessage(message)
builder.setPositiveButton("Continue") { _,_ -> handler.proceed() }
builder.setNegativeButton("Cancel") { _,_ -> handler.cancel() }
val dialog = builder.create()
dialog.show()
}
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
loadingProgressBar.visibility = View.VISIBLE
if (url == "https://www.bkash.com/terms-and-conditions") {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
return true
}
return false
}
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
loadingProgressBar.visibility = View.VISIBLE
}
override fun onPageFinished(view: WebView?, url: String?) {
bkashWebView.let {
it.loadUrl("javascript:callReconfigure($paymentRequest )")
it.loadUrl("javascript:clickPayButton()")
}
loadingProgressBar.visibility = View.GONE
}
}
You need to update WebViewClient interface to handle SSLError.
Otherwise, you will get Alert from google play store after publishing the app. You can try this bunch of code to handle