shouldUseNewSchemeHandler method

This method controls whether to use the new scheme handler for URLs.

Note:

  • The shouldUseNewSchemeHandler method takes effect only when the schemeTaskHandlerEnabled method returns YES .
  • This method is used for H5 containers only, and it has no effect for mini programs.

Method signature

copy
func shouldUseNewSchemeHandler(for url: URL) -> 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 to use the new scheme handler for URLs:

  • YES: use the new scheme handler configuration.
    Note: When YES is returned, call the shouldAssumesHTTP3Capable method to control whether to enable the HTTP/3 protocol for the first request of the specified URL.
  • NO: keep using the old, original scheme handler.

Sample

copy
class DemoSchemeTaskHandlerDelegate: NSObject, GRVSchemeTaskHandlerDelegate {
    func shouldUseNewSchemeHandler(for url: URL) -> Bool {
        if let host = url.host, host.contains("xxx") {
            return true
        }
        return false
    }
}