From Engineering Client Portal

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png iOS SDK API Reference breadcrumbArrow.png trackViewability

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.


Objective C

- (void)trackViewability:(nonnull NSDictionary *)data;


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];


let targetViewTag = targetView.tag
let controlsViewTag = controlsViewTag.tag
let activityIndicatorViewTag = activityIndicatorView.tag
let viewabilityData: [String:Any] = ["viewTag": "\(targetViewTag)",
                                     "viewContainer": targetView.window!,
                                     "friendlyObstructions": ["\(controlsViewTag)", "\(activityIndicatorViewTag)"]]

Input Parameters

Parameter Description
data NSDictionary object with the following objects and keys:
viewTag (mandatory) value of NSNumber type, unique identifier (tag) for the target view object. This tag can be assigned for the player view either programmatically or in the storyboard/xib.
viewContainer (mandatory) pointer to the parent view object. It is needed to identify the concrete scene in the applications which support multiple scenes. This parameter can not be nil.
friendlyObstructions (nullable) an array of tags of the views which should be ignored during the intersection ratio calculation. Those are views like loading activity indicator, player controls, view with a watermark, etc. which are displayed in front of the target view, but should not reduce the viewability intersection ratio. The tags of such should be wrapped into the NSNumber objects before adding into the array. This parameter is nullable, empty array is also accepted.

PlayerView FirendlyView(Timer & Slider).png

Output Parameters

Output Parameters (Return value) Description


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.