Class: VerificationClient

VerificationClient(communicationopt, nullable)

Allows verification scripts to interact with the OM SDK Service.

Constructor

new VerificationClient(communicationopt, nullable)

Parameters:
Name Type Attributes Description
communication Communication.<?> <optional>
<nullable>
This parameter is for OM SDK internal use only and should be omitted.
Source:

Members

communication

Communication object that the VerificationClient will use to talk to the VerificationService. This parameter is useful for testing. If left unspecified, the correct Communication will be constructed and used.
Source:

Methods

addEventListener(eventTypenon-null, functionToExecutenon-null)

Subscribes to ad lifecycle and metric events. The event handler will be called with a single argument that has the following fields: 'adSessionId': string, 'timestamp': number, 'type': string, 'data': object
Parameters:
Name Type Description
eventType AdEventType The event type to subscribe this listener to.
functionToExecute EventCallback An event handler to be invoked when the given event type is triggered.
Source:
Throws:
  • error if the event type is undefined, null or blank.
  • error if the function to execute is undefined or null.

clearInterval(intervalId)

Cancels further execution of a repeated callback.
Parameters:
Name Type Description
intervalId number The ID returned from setInterval of the callback to cancel.
Source:
Throws:
error if the interval ID is undefined, null or a non-positive number.

clearTimeout(timeoutId)

Cancels a timeout before its callback has been executed. Provides behavior equivalent to the window.clearTimeout web API method.
Parameters:
Name Type Description
timeoutId number The ID returned from setTimeout of the callback to cancel.
Source:
Throws:
error if the timeout ID is undefined, null or a non-positive number.

(protected) hasIntervalMethods_() → {boolean}

Checks to see if intrinsic interval methods are defined in the local execution context.
Source:
Returns:
Whether setInterval and clearInterval are defined.
Type
boolean

(protected) hasTimeoutMethods_() → {boolean}

Checks to see if intrinsic timeout methods are defined in the local execution context.
Source:
Returns:
Whether setTimeout and clearTimeout are defined.
Type
boolean

injectionSource() → {Environment|undefined}

Gets the environment type of the OM Service that injected the verification resource.
Source:
Returns:
the injecting service's environment type or undefined if the verification resource was side-loaded or the service is a 3rd party custom service.
Type
Environment | undefined

injectJavaScriptResource(url, successCallbackopt, failureCallbackopt)

Injects the supplied JavaScript resource into the same execution environment as the verification provider. For all DOM based environments (incl. Android native ad sessions) this will append `script` elements to the DOM. For native ad sessions this will delegate responsibility to the OM SDK library which will be responsible for downloading and injecting the JavaScript content into the execution environment.
Parameters:
Name Type Attributes Description
url string The URL of the JavaScript resource to load into the environment.
successCallback function <optional>
Optional callback to be executed if the HTTP request was successful. Does not indicate whether the script evaluation was successful.
failureCallback function <optional>
Optional callback to be executed if the script failed to load.
Source:
Throws:
error if the supplied URL is undefined, null or blank.

isSupported() → {boolean}

Checks if OMID is available.
Source:
Returns:
Type
boolean

registerSessionObserver(functionToExecute, vendorKeyopt)

Subscribes to all session events ('sessionStart', 'sessionError', and 'sessionFinish'). This method also signals that the verification script has loaded and is ready to receive events, so it should be called upon initialization. The event handler will be called with a single argument that has the following fields: 'adSessionId': string, 'timestamp': number, 'type': string, 'data': object
Parameters:
Name Type Attributes Description
functionToExecute SessionObserverCallback An event handler which will be invoked on session events.
vendorKey string <optional>
Source:
Throws:
  • error if the function to execute is undefined or null.
  • error if the vendor key is undefined, null or blank.

sendUrl(url, successCallbackopt, failureCallbackopt)

Requests the target URL. This can be used to transmit data to a remote server by requesting a URL with the payload embeded into the URL as query arg(s).
Parameters:
Name Type Attributes Description
url string The URL to be requested.
successCallback function <optional>
Optional callback to be executed if the request was successfully received (2xx response code).
failureCallback function <optional>
Optional callback to be executed if the request was not successfully received (non-success response code or other error).
Source:
Throws:
error if the url is undefined, null or blank.

setInterval(functionToExecute, timeInMillis) → {number}

Schedules a function to be called repeatedly at a specified interval. Provides behavior equivalent to the window.setInterval web API method.
Parameters:
Name Type Description
functionToExecute function The callback to execute repeatedly.
timeInMillis number The number of milliseconds to wait between callback invocations.
Source:
Throws:
  • error if the function to execute is undefined or null.
  • error if the time in millis is undefined, null or a non-positive number.
Returns:
A unique ID which can be used with clearInterval to cancel the function execution.
Type
number

setTimeout(functionToExecute, timeInMillis) → {number}

Schedules a function to be called a function after the specified delay. Provides behavior equivalent to the window.setTimeout web API method.
Parameters:
Name Type Description
functionToExecute function The callback to execute after the delay.
timeInMillis number The number of milliseconds to wait before invoking the callback.
Source:
Throws:
  • error if the function to execute is undefined or null.
  • error if the time in millis is undefined, null or a non-positive number.
Returns:
A unique ID which can be used with clearTimeout to cancel the function execution.
Type
number