Class: VerificationClient

VerificationClient(communicationnullable)

OMID VerificationClient. Allows verification scripts to interact with the OM SDK Service.

Constructor

new VerificationClient(communicationnullable)

Parameters:
Name Type Attributes Description
communication Communication.<?> <nullable>
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.

Methods

addEventListener(eventTypenon-null, functionToExecutenon-null)

Registers an event listener. Possible event types include: - stateChange - impression - geometryChange - video
Parameters:
Name Type Description
eventType AdEventType Event type to listen to.
functionToExecute EventCallback Callback to execute when the event fires.
Throws:
  • error if the event type is undefined, null or blank.
  • error if the function to execute is undefined or null.

clearInterval(intervalId)

Stops a function execution interval set by `setInterval`.
Parameters:
Name Type Description
intervalId number which should be stopped.
Throws:
error if the timeout id is undefined, null or a non-positive number.

clearTimeout(timeoutId)

Cancels a timeout before it has been executed.
Parameters:
Name Type Description
timeoutId number which should be canceled.
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.
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.
Returns:
Whether setTimeout and clearTimeout are defined.
Type
boolean

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 of the JavaScript resource you would like injected into the execution environment.
successCallback function <optional>
Called when the HTTP request is successful. Does not indicate whether the script evaluation was successful.
failureCallback function <optional>
Throws:
error if the supplied URL is undefined, null or blank.

isSupported() → {boolean}

Checks if OMID is available.
Returns:
Type
boolean

registerSessionObserver(functionToExecute, vendorKeyopt)

Registers a callback for session start and finish events triggered by the native ad session. This enables the JS component to keep in sync with the native layer - for example, ensure that the ad session has started prior to recording the impression event.
Parameters:
Name Type Attributes Description
functionToExecute SessionObserverCallback Called once either the session start or finish has been received.
vendorKey string <optional>
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 which should be requested.
successCallback function <optional>
function to be executed when the request has been successful.
failureCallback function <optional>
function to be executed when the request has failed.
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.
Parameters:
Name Type Description
functionToExecute function which should be executed once the interval has been reached.
timeInMillis number which you would like to wait before the callback function will be executed
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 interval id which can be used to cancel the function execution.
Type
number

setTimeout(functionToExecute, timeInMillis) → {number}

Calls a function after the specified time has elapsed.
Parameters:
Name Type Description
functionToExecute function which should be executed once the timeout has been reached.
timeInMillis number which you would like to wait before the callback function will be executed
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 timeout id which can be used with clearTimeout to cancel the function execution.
Type
number