Listen for the SSL error event
IAPMiniProgram SDK provides the ability to listen for the SSL error events.
Procedures
To listen for the SSL error events, complete the following steps:
Step 1: Implement the GriverReceivedSslErrorHandler interface
Implement GriverReceivedSslErrorHandler and write code in the required methods according to your business logic. See the following example for how to implement this interface.
class DemoGriverReceivedSslErrorHandler : GriverReceivedSslErrorHandler {
override fun onReceivedSslError(context: Context, handler: APSslErrorHandler, error: SslError) {
}
override fun onInitialized() {
}
override fun onFinalized() {
}
}Step 2: Register the DemoGriverReceivedSslErrorHandler class
Call the registerEventHandler API to register the SSL error event after initializing the SDK. Refer to the following sample code:
Griver.registerEventHandler(
GriverEventManifest(
DemoGriverReceivedSslErrorHandler::class.java.name, Arrays.asList(
GriverReceivedSslErrorHandler::class.java.name
),
App::class.java
)
)Structures
GriverReceivedSslErrorHandler interface
The definition of the GriverReceivedSslErrorHandler interface is shown in the following code:
interface GriverReceivedSslErrorHandler : GriverEvent {
fun onReceivedSslError(context: Context?, handler: APSslErrorHandler?, error: SslError?)
}Based on the definition, this interface provides the following methods:
Method Name | Description |
onReceivedSslError | When an SSL error occurred while loading a url. For details about the |
APSslErrorHandler interface
The definition of the APSslErrorHandler interface is shown in the following code:
interface APSslErrorHandler {
fun cancel()
fun proceed()
}Based on the definition, this interface provides the following methods:
Method Name | Description |
proceed | Proceeds with the SSL certificate. It is not recommended to proceed to past SSL errors and this method is generally not be used. |
cancel | Cancels this request. All requests for the WebView that has the SSL error are pending. |