OMID chapter navigation
VerificationClient
APIThe 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.
| Name | Signature | Returns | Official description |
|---|---|---|---|
| VerificationClient | new VerificationClient(communication) | void | (no official description provided)
|
| communication | 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. |
| addEventListener | addEventListener(eventType, functionToExecute) | void | 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
|
| attest | attest(requestPayload, callback) | void | Requests the attestation mechanism to be invoked. This can be used by the verification scripts to invoke the attestation mechanism supported by this device.
|
| clearInterval | clearInterval(intervalId) | void | Cancels further execution of a repeated callback.
|
| clearTimeout | clearTimeout(timeoutId) | void | Cancels a timeout before its callback has been executed. Provides behavior equivalent to the window.clearTimeout web API method.
|
| getEnvironment | 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. |
| injectJavaScriptResource | injectJavaScriptResource(url, successCallback, failureCallback) | void | 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.
|
| injectionSourcedeprecated | 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. |
| isSupported | isSupported() | boolean | Checks if OMID is available. |
| registerSessionObserver | registerSessionObserver(functionToExecute, vendorKey) | void | 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
|
| sendUrl | sendUrl(url, successCallback, failureCallback) | void | 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).
|
| setInterval | 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.
|
| setTimeout | 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.
|
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
| Concept | JavaScript | iOS | Android |
|---|---|---|---|
| script-injector | — | OMIDScriptInjector | ScriptInjector |
| sdk-entry | — | OMIDSDK | Omid |
| verification-client | VerificationClient | — | — |
- 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.