trackViewability
From Engineering Client Portal
Viewability support requires additional parameters to be provided from player applications to the SDK. In order to provide those parameters and to start the viewability measurement trackViewability
method is added to the public SDK API.
Syntax
Objective C
- (void)trackViewability:(nonnull NSDictionary *)data;
Swift
func trackViewability(_ data: [String : Any])
Calling trackViewability for player view
Objective C
NSString *targetViewTag = targetView.tag;
NSString *controlsViewTag = controlsViewTag.tag;
NSString *activityIndicatorViewTag = activityIndicatorView.tag;
NSDictionary *viewabilityData = @{@"viewTag": targetViewTag,
@"viewContainer": targetView.window,
@"friendlyObstructions": @[controlsViewTag, activityIndicatorViewTag]};
[sdkInstance trackViewability:viewabilityData];
Swift
let targetViewTag = targetView.tag
let controlsViewTag = controlsViewTag.tag
let activityIndicatorViewTag = activityIndicatorView.tag
let viewabilityData: [String:Any] = ["viewTag": "\(targetViewTag)",
"viewContainer": targetView.window!,
"friendlyObstructions": ["\(controlsViewTag)", "\(activityIndicatorViewTag)"]]
sdkInstance.trackViewability(viewabilityData)
Input Parameters
Parameter | Description | ||||||
---|---|---|---|---|---|---|---|
data | NSDictionary object with the following objects and keys:
|
Output Parameters
Output Parameters (Return value) | Description |
---|---|
Void |
Notes
If incorrect view tag is provided, SDK will not be able to measure viewability metrics. Viewability engine tries to find a view for the provided tag during 15 seconds and if it is not found it goes to inactive state. In order to restart the viewability engine it is required to call trackViewability with a proper tag again.