GRVSchemeTaskHandlerDelegate(Optional)

When opening web-view pages, the web_viewSchemeTaskHandlerEnabled method of the GRVSchemeTaskHandlerDelegate can control whether to use the mini program internal configuration rather than the defaut settings (WKWebViewConfiguration).

Procedures

Step 1. Implement the GRVSchemeTaskHandlerDelegate delegate

Implement the GRVSchemeTaskHandlerDelegate delegate and write code in the required methods according to your business logic.

Code sample as follows:

copy
class DemoSchemeTaskHandlerDelegate: NSObject, GRVSchemeTaskHandlerDelegate {
    func web_viewSchemeTaskHandlerEnabled(forURL url: String) -> Bool {
        var enable = true
        if let u = URL(string: url), let host = u.host() {
            let blackList = [
                "url"
            ]
            return !blackList.contains(host)
        }
        return true
    }
}

Step 2. Configure the GRVSchemeTaskHandlerDelegate delegate

Configure the GRVExtensionDelegate interface to register the GRVSchemeTaskHandlerDelegate delegate after initializing the SDK.

Delegates

GRVSchemeTaskHandlerDelegate delegate

Based on the definition above, this interface provides the following method:

Method

Description

web_viewSchemeTaskHandlerEnabled

This method is used for web-view containers only.

web_viewSchemeTaskHandlerEnabled method

Method signature

This function determines whether the web view scheme task handler is enabled.

copy
func web_viewSchemeTaskHandlerEnabled(forURL url: String) -> Bool

Parameters

Parameter

Data type

Required

Description

url

String

Yes

Indicates the URL of the web-view page to open.

Default value: "YES" (indicates all URLs)

Return value

Parameter

Data type

Required

Description

N/A

BOOL

Yes

Return the result of whether mini program's internal configuration is used for web view:

  • YES: Indicates to use the mini program's internal configuration.
  • NO: Indicates to use the webview default settings.