Contents

matchesURL(_:)

Checks whether a given URL matches the callback object.

Declaration

func matchesURL(_ url: URL) -> Bool

Discussion

Use this method in a browser app that adopts the ASWebAuthenticationWebBrowser API. Other apps can use it for debugging purposes.

The following example shows how a browser app’s internal method for determining redirect policies might use matchesURL(_:):

// The pre-existing delegate method, which the system calls when the web browser receives a request from an app.
func begin(_ request: ASWebAuthenticationSessionRequest!) {
    self.request = request

    // Load the URL request.
}

// The web browser's internal method for determining redirect policies.
func myShouldNavigate(to url: URL) -> Bool {
    if request.callback.matches(url) {
        // Existing API to complete a request.
        request.complete(withCallbackURL: url)
    }
    ...
}