TOP > Viewability Measurement Provider
RUNAViewabilityProvider helps to detect the viewability of an arbitrary target UIView.
Create A RUNAMeasurableTarget
instance to refer a UIView as the view-ability measuring target
and enable desired measurement methods by setting required configurations.
The RUNAMeasurableTarget
support both two method of measurements, RUNA and OM(open measurement)
viewImpURL
: a URL to be sent when view ability measureredcompletionHandler
: custom handler invoked when view ability measurered
verificationJsURL
: verification JS URL for vendorproviderURL
: OMSDK JS URLvendorKey
: key for vendorvendorParameters
: parameters for vendor
let target = RUNAMeasurableTarget(view: aTargetView)
let runaConfig = RUNAMeasurementConfiguration()
runaConfig.viewImpURL = "<aImpURL>"
runaConfig.completionHandler = { (view) in
print("viewability decteded")
}
let omConfig = RUNAOMNativeProviderConfiguration()
omConfig.verificationJsURL = "https://verification.js"
omConfig.providerURL = "https://provider.SDK.js"
omConfig.vendorKey = "<key>"
omConfig.vendorParameters = "<parameters>"
Register the configured target instance to the RUNAViewabilityProvider
instance and start detecting the target's viewability state.
The target will be considered as viewable state When it is show within the screen at a size larger than 50% of its complete size.
RUNAViewabilityProvider.sharedInstance().register(target)
Unregister the target UIView to release reference retainment When dismissing.
import RUNABanner
var targetView: UIView!
override func viewDidLoad() {
// ...
// start measurement when targetView loaded
let target = RUNAMeasurableTarget(view: targetView)
let runaConfig = RUNAMeasurementConfiguration()
runaConfig.viewImpURL = "<aImpURL>"
runaConfig.completionHandler = { (view) in
print("viewability decteded")
}
let omConfig = RUNAOMNativeProviderConfiguration()
omConfig.verificationJsURL = "https://verification.js"
omConfig.providerURL = "https://provider.SDK.js"
omConfig.vendorKey = "<key>"
omConfig.vendorParameters = "<parameters>"
RUNAViewabilityProvider.sharedInstance().register(target)
}
// stop measurement
override func viewDidDisappear(_ animated: Bool) {
// ...
// unregister targetView when view disappear
RUNAViewabilityProvider.sharedInstance().unregisterTargetView(targetView)
}
LANGUAGE :