ORTB
OMID chapter navigation

VerificationClient

API

The listings on this page are generated by scripts/gen-omid-spec.mjs from official IAB Tech Lab sources, with descriptions in the original English; see the page footer for the collection baseline.

On this page

Role & scope

The verification client is what a measurement vendor's verification script uses: registerSessionObserver subscribes to session events, addEventListener subscribes to a specific event type, sendUrl and injectJavaScriptResource perform network requests and script injection in restricted environments, setTimeout / setInterval provide controlled timers, and attest (device attestation) was added in 1.6.0.

Client
Verification client
Platform
JavaScript
Library version
1.6.10
Public members
14

API surface

VerificationClientjs · 14

Allows verification scripts to interact with the OM SDK Service.

NameSignatureReturnsOfficial description
VerificationClientnew VerificationClient(communication)void(no official description provided)
  • communication: Communication<?>This parameter is for OM SDK internal use only and should be omitted.
communicationcommunicationCommunication 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.
addEventListeneraddEventListener(eventType, functionToExecute)voidSubscribes 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
  • eventType: AdEventTypeThe event type to subscribe this listener to.
  • functionToExecute: EventCallbackAn event handler to be invoked when the given event type is triggered.
attestattest(requestPayload, callback)voidRequests the attestation mechanism to be invoked. This can be used by the verification scripts to invoke the attestation mechanism supported by this device.
  • requestPayload: AttestRequestPayloadcontains attestation details like mechanism name, version and mechanism specific payload
  • callback: AttestCallbackcallback to be executed.
clearIntervalclearInterval(intervalId)voidCancels further execution of a repeated callback.
  • intervalId: numberThe ID returned from setInterval of the callback to cancel.
clearTimeoutclearTimeout(timeoutId)voidCancels a timeout before its callback has been executed. Provides behavior equivalent to the window.clearTimeout web API method.
  • timeoutId: numberThe ID returned from setTimeout of the callback to cancel.
getEnvironmentgetEnvironment()Environment|nullGets 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.
injectJavaScriptResourceinjectJavaScriptResource(url, successCallback, failureCallback)voidInjects 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.
  • url: stringThe URL of the JavaScript resource to load into the environment.
  • successCallback: function()Optional callback to be executed if the HTTP request was successful. Does not indicate whether the script evaluation was successful.
  • failureCallback: function()Optional callback to be executed if the script failed to load.
injectionSourcedeprecatedinjectionSource()Environment|undefinedDEPRECATED: use getEnvironment to cover both injected and inline scripts. Gets the environment type of the OM Service that injected the verification resource.
isSupportedisSupported()booleanChecks if OMID is available.
registerSessionObserverregisterSessionObserver(functionToExecute, vendorKey)voidSubscribes 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
  • functionToExecute: SessionObserverCallbackAn event handler which will be invoked on session events.
  • vendorKey: string
sendUrlsendUrl(url, successCallback, failureCallback)voidRequests 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).
  • url: stringThe URL to be requested.
  • successCallback: function()Optional callback to be executed if the request was successfully received (2xx response code).
  • failureCallback: function()Optional callback to be executed if the request was not successfully received (non-success response code or other error).
setIntervalsetInterval(functionToExecute, timeInMillis)numberSchedules a function to be called repeatedly at a specified interval. Provides behavior equivalent to the window.setInterval web API method.
  • functionToExecute: function()The callback to execute repeatedly.
  • timeInMillis: numberThe number of milliseconds to wait between callback invocations.
setTimeoutsetTimeout(functionToExecute, timeInMillis)numberSchedules a function to be called a function after the specified delay. Provides behavior equivalent to the window.setTimeout web API method.
  • functionToExecute: function()The callback to execute after the delay.
  • timeInMillis: numberThe number of milliseconds to wait before invoking the callback.
docs.iabtechlab.com/omsdk-1.6/js/VerificationClient.html

Members the official source marks as friend scoped (not to be exported beyond obfuscation) are filtered out of this table; the public path for impression and creative load is AdEvents.

Subscription model

A verification script has two ways to subscribe, and the callback shape is the same for both: the handler receives a single argument with the fields adSessionId: string, timestamp: number, type: string, data: object.

  • registerSessionObserver(functionToExecute, vendorKey) subscribes to all session events (sessionStart, sessionError, sessionFinish). The call also signals that the verification script has loaded and is ready to receive events, which is why the official text says it should be called upon initialization.
  • addEventListener(eventType, functionToExecute) subscribes to ad lifecycle and metric events. The official description of registerSessionObserver lists only those three session events, so geometryChange, impression and the media events in AdEventType arrive through addEventListener.
  • injectionSource() is deprecated: the official text says to use getEnvironment() instead, because it covers both injected and inline scripts.

Substitutes in restricted environments

A verification script may run in a cross-domain iframe, an invisible WebView, or the DOM-less JavaScript execution environment of a native ad session, where the usual capabilities on the global object are unavailable. The verification client provides equivalents:

  • sendUrl(url, successCallback, failureCallback): requests the target URL, which can transmit data to a remote server by embedding the payload in the URL as query arguments.
  • injectJavaScriptResource(url, successCallback, failureCallback): injects the supplied JavaScript resource into the same execution environment as the verification provider. In DOM-based environments (including Android native ad sessions) it appends script elements to the DOM; for native ad sessions it delegates downloading and injecting the content to the OM SDK library.
  • setTimeout / clearTimeout / setInterval / clearInterval: the official text states these provide behaviour equivalent to the same-named window web API methods.
  • getEnvironment(): returns the environment type of the OM Service that either injected the verification resource or is present in the global context (e.g. window). The official text notes the check is based on which service binary is used — omsdk-v1.js for App, omweb-v1.js for Web — and that the binary usually corresponds to the actual environment, with counterexamples such as the Web service binary running in a webview inside a mobile app.
  • isSupported(): checks whether OMID is available.
  • attest(attestPayload, callback): requests that the attestation mechanism supported by this device be invoked, for verification scripts to use (device attestation since OM SDK 1.6.0).

Cross-platform naming

ConceptJavaScriptiOSAndroid
script-injectorOMIDScriptInjectorScriptInjector
sdk-entryOMIDSDKOmid
verification-clientVerificationClient
  • script-injectorOMIDScriptInjector on iOS / ScriptInjector on Android: inject verification script content into an HTML creative. On the JS side the OM SDK service does this and publishes no class.
  • sdk-entryOMIDSDK on iOS (+sharedInstance / -activate) and Omid on Android (activate(Context) / isActive()); there is no JS counterpart class, as the service script is loaded by the OM SDK service itself.
  • verification-clientPublished on JS only: verification scripts (third-party measurement) always use the JS OmidVerificationClient; the native SDKs contain no verification client.

Class names for the same concept on each of the three platforms; a blank cell means that platform provides no corresponding class. On the JS side session configuration is folded into Context and the constructor arguments, while iOS / Android split it into separate configuration and context classes.

Content is taken from official IAB Tech Lab sources (the OM SDK JS repository, the three platforms' official API docs, the OpenRTB support advisory and the VAST specification); spec data is kept in the original English and site-written prose is bilingual. See data/omid-spec/PROVENANCE.json for provenance.