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. |
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.
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. |
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. |
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. |
Throws:
error if the timeout ID is undefined, null or a non-positive
number.
getEnvironment() → {Environment|null}
Gets the environment type of the OM Service that either injected the
verification resource or is present in the global context (e.g. window).
Note that this check is based on which service binary is used: omsdk-v1.js
(App) or omweb-v1.js (Web). The binary typically corresponds to the actual
environment in which the OM SDK is run, but there may be counterexamples
such as the Web service binary running in a webview inside a mobile app.
Returns:
The service's environment type; null if either
(1) the service is a 3rd party custom service or (2) this verification
client is inlined (not injected) and the service is version 1.4.7 or below.
- Type
- Environment | null
(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 | 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. |
Throws:
error if the supplied URL is undefined, null or blank.
injectionSource() → {Environment|undefined}
DEPRECATED: use getEnvironment to cover both injected and inline scripts.
Gets the environment type of the OM Service that injected the verification
resource.
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
isSupported() → {boolean}
Checks if OMID is available.
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> |
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). |
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. |
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. |
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