UAURLAllowList

Objective-C

@interface UAURLAllowList : NSObject

Swift

class UAURLAllowList : NSObject

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

URL Allow list Properties

URL Allow list Creation

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

    Note

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

    Declaration

    Objective-C

    + (nonnull instancetype)allowListWithConfig:(nonnull UARuntimeConfig *)config;

    Swift

    convenience init(config: UARuntimeConfig)

    Parameters

    config

    An instance of UARuntimeConfig.

    Return Value

    An instance of UAURLAllowList

URL allow list Core Methods

  • Add an entry to the URL allow list, with the implicit scope UAURLAllowListScopeAll.

    Declaration

    Objective-C

    - (BOOL)addEntry:(nonnull NSString *)patternString;

    Swift

    func addEntry(_ patternString: String) -> Bool

    Parameters

    patternString

    A URL allow list pattern string.

    Return Value

    YES if the URL allow list pattern was validated and added, NO otherwise.

  • Add an entry to the URL allow list.

    Declaration

    Objective-C

    - (BOOL)addEntry:(nonnull NSString *)patternString
               scope:(UAURLAllowListScope)scope;

    Swift

    func addEntry(_ patternString: String, scope: UAURLAllowListScope) -> Bool

    Parameters

    patternString

    A URL allow list pattern string.

    scope

    The scope of the pattern.

    Return Value

    YES if the URL allow list pattern was validated and added, NO otherwise.

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

    Declaration

    Objective-C

    - (BOOL)isAllowed:(nonnull NSURL *)URL;

    Swift

    func isAllowed(_ URL: URL) -> Bool

    Parameters

    URL

    The URL under consideration.

    Return Value

    YES if the the URL is allowed, NO otherwise.

  • Determines whether a given URL is allowed.

    Declaration

    Objective-C

    - (BOOL)isAllowed:(nonnull NSURL *)URL scope:(UAURLAllowListScope)scope;

    Swift

    func isAllowed(_ URL: URL, scope: UAURLAllowListScope) -> Bool

    Parameters

    URL

    The URL under consideration.

    scope

    The scope of the desired match.

    Return Value

    YES if the the URL is allowed, NO otherwise.