Constructor
new AdSession(contextnon-null, communicationopt, nullable, sessionInterfaceopt, nullable)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
context |
Context | that provides the required information for initialising the JS ad session. | |
communication |
Communication.<?> |
<optional> <nullable> |
This parameter is for OM SDK internal use only and should be omitted. |
sessionInterface |
OmidJsSessionInterface |
<optional> <nullable> |
This parameter is for OM SDK internal use only and should be omitted. |
- Source:
Throws:
error if the supplied context is undefined or null.
Methods
assertSessionRunning()
Throws an error if the session is not running.
NOTE: This method is friend scoped. Therefore it should not be exported
beyond obfuscation.
- Source:
creativeLoaded()
Handles when a load event has occurred.
Sets a flag of this class so that it can remember that a loaded event
has occured.
NOTE: This method is friend scoped. Therefore it should not be exported
beyond obfuscation.
- Source:
Throws:
error if creativeType or impressionType has not be redefined
from the JS layer. Both the creative and impression types must be redefined
by the JS layer before the loaded event can be sent from the JS layer.
error(errorTypenon-null, message)
Notifies that an error has occurred on the ad session.
All verification clients will be notified via the 'sessionError' session
observer event.
Parameters:
Name | Type | Description |
---|---|---|
errorType |
ErrorType | High level error type. |
message |
string | Description of the session error. |
- Source:
finish()
If there is a currently active ad session, this notifies all session
observers that the ad session has finished with a SESSION_FINISH event.
This ceases ad view tracking and message sending to verification scripts
injected for the ad session. This method has no effect if called if there
is no active ad session or in a mobile app environment.
- Source:
getAdSessionId() → {string}
Get the ID of this ad session.
- Source:
Returns:
- Type
- string
impressionOccurred()
Handles when an impression has occurred.
Sets a flag of this class so that it can remember that an impression has
occured.
NOTE: This method is friend scoped. Therefore it should not be exported
beyond obfuscation.
- Source:
Throws:
error if creativeType or impressionType has not be redefined
from the JS layer. Both the creative and impression types must be redefined
by the JS layer before the impression event can be sent from the JS layer.
isSupported() → {boolean}
Returns true if OMID is available, false otherwise.
- Source:
Returns:
- Type
- boolean
registerAdEvents()
Registers the existence of an AdEvent instance.
- Source:
registerMediaEvents()
Registers the existence of an MediaEvents instance.
- Source:
registerSessionObserver(functionToExecute)
Subscribes to all session events ('sessionStart', 'sessionError', and
'sessionFinish').
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 |
---|---|---|
functionToExecute |
function | An event handler which will be invoked on session events. |
- Source:
sendMessage(method, responseCallbacknullable, …args)
Sends a message to the OMID SessionService.
NOTE: This method is friend scoped. Therefore it should not be exported
beyond obfuscation.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
method |
string | Name of the remote method to invoke. | |
responseCallback |
function |
<nullable> |
Callback to be called when a response is received. |
args |
? |
<repeatable> |
Arguments to use when invoking the remote function. |
- Source:
sendOneWayMessage(method, …args)
Sends a message to the OMID VerificationService and ignores responses.
NOTE: This method is friend scoped. Therefore it should not be exported
beyond obfuscation.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
method |
string | Name of the remote method to invoke. | |
args |
? |
<repeatable> |
Arguments to use when invoking the remote function. |
- Source:
setCreativeType(creativeTypenon-null)
Specifies the type of creative to be rendered in this session.
Requires that the native layer set the creative type to
DEFINED_BY_JAVASCRIPT.
Parameters:
Name | Type | Description |
---|---|---|
creativeType |
CreativeType | The type of creative. |
- Source:
Throws:
-
error if arg type is DEFINED_BY_JAVASCRIPT.
-
error if impression has already occured.
-
error if creative has already loaded.
-
error if creativeType was already defined to something other than DEFINED_BY_JAVASCRIPT.
-
error if native integration has started and is using OMID 1.2 or earlier.
setElementBounds(elementBoundsnullable)
Set the DOM element's geometry relative to the geometry of either the
slotElement or the cross domain iframe the creative's DOM element is in.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elementBounds |
Rectangle |
<nullable> |
- Source:
Throws:
Error if the elementBounds parameter is null or undefined.
setImpressionType(impressionTypenon-null)
Specifies the type of impression to be triggered in this session.
Requires that the native layer set the impression type to
DEFINED_BY_JAVASCRIPT.
Parameters:
Name | Type | Description |
---|---|---|
impressionType |
ImpressionType | The type of impression. |
- Source:
Throws:
-
error if arg type is DEFINED_BY_JAVASCRIPT
-
error if impression has already occurred
-
error if impressionType was already defined to something other than DEFINED_BY_JAVASCRIPT.
-
error if native integration has started and is using OMID 1.2 or earlier.
start()
If there is no currently active ad session, this notifies all session
observers that an ad session has started with a SESSION_START event.
This starts ad view tracking and makes video and ad events available to
send to verification scripts injected for this ad session. This method
has no effect if called after the ad session has already started or in a
mobile app environment.
- Source: