GRVSchemeTaskHandlerDelegate(Required)

When opening H5 pages, the schemeTaskHandlerEnabled 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: This is a "Domain Blacklist" filter. Any URL that matches the blacklist is strictly prohibited from using the app Scheme-Task process. All other cases are permitted.

copy
class DemoSchemeTaskHandlerDelegate: NSObject, GRVSchemeTaskHandlerDelegate {
    func schemeTaskHandlerEnabled(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

schemeTaskHandlerEnabled

This method controls whether mini program's internal configuration is used.

Note: This method is used for H5 containers only, and it has no effect for mini programs.

schemeTaskHandlerEnabled method

Method signature

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

Parameters

Parameter

Data type

Required

Description

url

String

Yes

Indicates the URL of the H5 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:

  • YES: Indicates to use the mini program internal configuration.
    Note: When YES is returned, call the shouldUseNewSchemeHandler method to control whether to use the new scheme handler to process URLs.
  • NO: Indicates to use the default settings.