URLAllowList

@objc(UAURLAllowList)
public final class URLAllowList : NSObject, URLAllowListProtocol

Class for accepting and verifying webview URLs.

URL allow list entries are written as URL patterns with optional wildcard matching:

<scheme> := <any char combination, '*' are treated as wildcards>

<host> := '*' | '*.'<any char combination except '/' and '*'> | <any char combination except '/' and '*'>

<path> := <any char combination, '*' are treated as wildcards>

<pattern> := '*' | <scheme>://<host>/<path> | <scheme>://<host> | <scheme>:/<path> | <scheme>:///<path>

A single wildcard will match any URI. Wildcards in the scheme pattern will match any characters, and a single wildcard in the scheme will match any scheme. The wildcard in a host pattern "*.mydomain.com" will match anything within the mydomain.com domain. Wildcards in the path pattern will match any characters, including subdirectories.

Note that NSURL does not support internationalized domains containing non-ASCII characters. All URL allow list entries for internationalized domains must be in ASCII IDNA format as specified in https://tools.ietf.org/html/rfc3490

  • Create a default URL allow list with entries specified in a config object.

    Note

    The entry “*.urbanairship.com” is added by default.

    Declaration

    Swift

    @objc
    @MainActor
    public static func allowListWithConfig(_ config: RuntimeConfig)
        -> URLAllowList

    Parameters

    config

    An instance of UARuntimeConfig.

    Return Value

    An instance of UAURLAllowList

  • The URL allow list delegate.

    Note

    The delegate is not retained.

    Declaration

    Swift

    @objc
    public weak var delegate: URLAllowListDelegate?
  • Add an entry to the URL allow list, with the implicit scope URLAllowListScope.all.

    Declaration

    Swift

    @discardableResult
    public func addEntry(_ patternString: String) -> Bool

    Parameters

    patternString

    A URL allow list pattern string.

    Return Value

    true if the URL allow list pattern was validated and added, false otherwise.

  • Add an entry to the URL allow list.

    Declaration

    Swift

    @discardableResult
    public func addEntry(
        _ patternString: String,
        scope: URLAllowListScope
    ) -> Bool

    Parameters

    patternString

    A URL allow list pattern string.

    scope

    The scope of the pattern.

    Return Value

    true if the URL allow list pattern was validated and added, false otherwise.

  • Determines whether a given URL is allowed, with the implicit scope URLAllowListScope.all.

    Declaration

    Swift

    public func isAllowed(_ url: URL?) -> Bool

    Parameters

    url

    The URL under consideration.

    Return Value

    true if the URL is allowed, false otherwise.

  • Determines whether a given URL is allowed.

    Declaration

    Swift

    public func isAllowed(_ url: URL?, scope: URLAllowListScope) -> Bool

    Parameters

    url

    The URL under consideration.

    scope

    The scope of the desired match.

    Return Value

    true if the URL is allowed, false otherwise.