From Engineering Client Portal

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png DCR & DTVR breadcrumbArrow.png DCR Video iOS SDK


The Nielsen SDK is one of multiple framework SDKs that Nielsen provides to enable measuring linear (live) and on-demand TV viewing using TVs, mobile devices, etc. The App SDK is the framework for mobile application developers to integrate Nielsen Measurement into their media player applications. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings (DCR & DTVR), Digital Ad Ratings (DAR), and Digital Audio. Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:

  • Application launch events and how long app was running
  • Time of viewing a sub section / page in the application.


To start using the App SDK, the following items are required:

Item Description Source
App ID (appid) Unique ID assigned to the player/site and configured by product. Contact Nielsen
sfcode Environment that the SDK must point to Contact Nielsen
Nielsen SDK Includes SDK libraries and sample implementation; See iOS SDK Release Notes Download

If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team. Refer to Digital Measurement Onboarding guide for information on how to get a Nielsen App SDK and appid.





This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.

Setting up your Development Environment

Prior to SDK Version the IOS framework has been distributed as a static library packaged into framework bundle format. Apple recommends to use dynamic framework, it has some benefits over static libraries like less executable file size of an app, faster startup time and native support in xCode IDE. Nielsen AppSDK has been transformed into dynamic framework in this release (static framework is still available).

If migrating from the static library to this new dynamic framework, once implemented, unless your specific application requires, you can remove the following Frameworks that were once required: [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++]

The Dynamic framework is created as a fat framework. It means that it contains slices required for devices (armv7, arm64) as well as slices required for simulators (i386, x86_64). Simulator slices are needed to let clients build and debug their app on the simulators, but they should be removed before sending the app to the AppStore. The example of the shell script that should be added as a Run Script phase in the application can be found below.

How to obtain the NielsenAppApi.Framework

The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of a CocoaPod or Gradle.

Configuring Xcode Development Environment

Starting with SDK version, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above. In addition, the framework support modules, so all the required frameworks are linked automatically as the are needed. More details can be found here: https://stackoverflow.com/questions/24902787/dont-we-need-to-link-framework-to-xcode-project-anymore

Note: All communications between the SDK and the Census (Collection Facility) use HTTPS.

Download Framework

The first step is to download and copy the NielsenAppApi.framework bundle to the app project directory.

Add Framework

In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.

Add Path

Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.

Import Framework

Add NielsenAppApi.framework module in the source file of your app:

Using Swift

To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.

  • Select File/New File/Objective-C File
  • Xcode will prompt you to create a bridging header.
bridgingheader 2x.png

Once this file has been created, you need to add the following:

#import <NielsenAppApi/NielsenAppApi.h>

Using Objective-C

Add the code to the View Controller’s header file.

#import <NielsenAppApi/NielsenAppApi.h>

SDK Initialization

The latest version of the Nielsen App SDK allows instantiating multiple instances of the SDK object, which can be used simultaneously without any issue. The sharedInstance API that creates a singleton object was deprecated prior to version 5.1.1. (Version 4.0 for Android)

The following table contains the list of arguments that can be passed via the AppInfo JSON schema.

  • The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.
Parameter / Argument Description Source Required? Example
appid Unique id for the application assigned by Nielsen. It is GUID data type. Nielsen-specified Yes PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
appname Name of the application Client-defined Optional; automatically detected in SDK and above Nielsen Sample App
sfcode Nielsen collection facility to which the SDK should connect.


  • "us"

Digital Audio

  • "drm"


  • "dcr"
Nielsen-specified Yes dcr
containerID View ID of the UI element used as player view in application for Viewability Client-defined Optional "1234567"
nol_devDebug Enables Nielsen console logging. Only required for testing Nielsen-specified Optional "DEBUG"

Debug flag for development environment

Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag, Pass the argument @"nol_devDebug":@"INFO", in the JSON string . The permitted values are:

  • INFO: Displays the API calls and the input data from the application (validate player name, app ID, etc.). It can be used as certification Aid.
  • WARN: Indicates potential integration / configuration errors or SDK issues.
  • ERROR: Indicates important integration errors or non-recoverable SDK issues.
  • DEBUG: Debug logs, used by the developers to debug more complex issues.

Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.

Note: DO NOT activate the Debug flag in a production environment.

Sample SDK Initialization Code


Swift 4.0 Example: NielsenInit.swift

import Foundation
import NielsenAppApi

class NielsenInit : NSObject {
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -> NielsenAppApi?{
        let appInformation:[String: String] = [
            "appid": "PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX",
            "sfcode": "dcr",
            "nol_devDebug": "DEBUG"
            "containerId": String(containerId)   //Keep container id unique constant, you can use tag property of player.
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)

Sample code using AVPlayer. ViewController.swift

class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {

// your code//    

  override func viewDidLoad() {

        //Getting the instance of NielsenApi
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)


Objective C

Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:

If App SDK is initialized using init or new methods, it will ignore the API calls resulting in no measurement. The SDK will not return any errors.
#import "NielsenInit.h"
#import <NielsenAppApi/NielsenEventTracker.h>

@implementation NielsenInit

+ (NielsenEventTracker *)createNielsenEventTrackerWithDelegate:(id<NielsenEventTrackerDelegate>)delegate
    //Initialising the NielsenEventTracker class by passing app information which returns the instance of NielsenEventTracker.
    NSDictionary *appInformation = @{ @"appid": @"PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX",
                            @"appversion": @"1.0",
                            @"sfcode": @"dcr",
                            @"nol_devDebug": @"DEBUG",
                            @"containerId": @"1" };
    return [[NielsenEventTracker alloc] initWithAppInfo:appInformation delegate:delegate];


The following would be the NielsenInit.h file:

#import <Foundation/Foundation.h>

@class NielsenEventTracker;
@protocol NielsenEventTrackerDelegate;

@interface NielsenInit : NSObject

+ (NielsenEventTracker *)createNielsenEventTrackerWithDelegate:(id<NielsenEventTrackerDelegate>)delegate;


APP SDK Error & Event Codes

To view the Error and Event codes for iOS and Android, please review the App SDK Event Code Reference page.

Configure Payload

Handling JSON Metadata

All the SDK methods handles only two types of objects: NSString, NSDictionary. The parameters passed must be either a JSON formatted string or a NSDictionary object. The JSON passed in the SDK must be well-formed.

  • NSDictionary object
    • If an object of unexpected type is passed to the method, the error message will be logged.
    • If string has invalid JSON format, the error message will be logged.
  • JSON value must be string value.
    • This includes boolean and numeric values. For example, a value of true should be represented with "true", number value 123 should be "123".
    • All the Variable Names like appid, appname, sfcode, dataSrc, title, type etc. are case-sensitive. Use the correct variable name as specified in the documentation.
  • JSON string can be prepared using either raw NSString or serialized NSDictionary.


let channelInfo = [
            "channelName": "My Channel Name 1",
let contentMetadata = [
 "type": "content",
 "assetid": "88675545",
 "title": "Program S3, EP1",
 "program":"Program Name",
 "airdate":"20171020 10:05:00",
 "segB":"CustomSegmentValueB",  //optional
 "segC":"CustomSegmentValueC",  //optional

Objective C

NSDictionary  *channelInfo = @
  @"channelname":@"My Channel Name 1",

NSDictionary *contentMetadata = @
  {@"type": @"content",
  @"length": @"3600",
  @"airdate":@"20180120 10:00:00",
  @"segB": @"CustomSegmentValueB",   //optional
  @"segC": @"CustomSegmentValueC",  //optional

Configure metadata

channelName should remain constant throughout the completion of an episode or live stream.

Key Description Values Required
channelName ChannelInfo refers to the Channel name. This can be a free-form value

value such as a friendly name for the content being played. the SDK
will pass the application name automatically.

custom No

Content metadata

Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.

Keys Description Values Required
type type of asset "content" Yes
assetid unique ID assigned to asset custom Yes
program name of program (25 character limit) ProgramName Yes
title name of program (40 character limit) Program S3, EP1 Yes
length length of content in seconds seconds (86400 for live stream) Yes
airdate the airdate in the linear TV YYYYMMDD HH24:MI:SS Yes
isfullepisode full episode flag "y"- full episode, "n"- non full episode Yes
adloadtype type of ad load:

"1" Linear – matches TV ad load

"2" Dynamic – Dynamic Ad Insertion (DAI)

"2" - DCR measures content with dynamic ads Yes
segB custom segment B custom
segC custom segment C custom
crossId1 standard episode ID custom
crossId2 content originator (only required for distributors) custom

Custom segments (segB and segC) can be used to aggregate video and/or static content within a single Brand to receive more granular reports within a brand.

Examples regarding usage of segments within SDK:

  • All comedy clips and stories for a Brand rolled into a “Comedy” segment
  • genre grouping content by Comedy vs. Drama
  • group related Text + Video content - i.e. for a show that has a lot of - static pages associated with it
  • packaging based on how clients sell inventory
  • grouping related types of content either by genre, category or platform.

Ad Metadata

The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins.

Keys Description Values Required
type ad vs content 'ad'
assetid unique ID assigned to ad custom

Example Ad Object

// create ad object
"ad": {
  "type": "preroll",
  "assetid": "AD-ID123"

Configure API Calls


Sample API Sequence

A Sample API sequence could follow this flow:

Type Sample code Description
On App Start [nielsenMeter loadMetadata: contentMetadata]; // contentMetadata Object contains the JSON metadata for the impression
Start of stream [nielsenMeter play: channelName]; // channelName now automatically generated by Nielsen SDK
[nielsenMeter loadMetadata: contentMetadataObject]; // contentMetadataObject contains the JSON metadata for the content being played
Content [nielsenMeter playheadPosition: position]; // playheadPosition is position of the playhead while the content is being played
End of Stream [nielsenMeter end]; // Content playback is completed.

SDK Events

Event Parameter Description
'loadMetadata' content/ad metadata object Needs to be called at the beginning of each asset
'playheadPosition' playhead position as integer

VOD: current position in seconds
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC)
Note: 'PlayheadPosition' has to be called every second

Pass playhead position every second during playback

'stop' playhead position Call when content or ads complete playing and pass playhead position
'end' playhead position in seconds Call when the current video asset completes playback and pass the playhead position.

Example: At the end of the content stream, if the user switches to another piece of content, when the browser is refreshed or closed.

Note: For livestream, send the UNIX timestamp, for VOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling stop, end or loadmetadata,.

Life cycle of SDK instance

Life cycle of SDK instance includes four general states:

  1. Initial state – The SDK is not initialized and hence, not ready to process playing information. Once the SDK is moved out of this state, it needs instantiation of the new SDK instance in order to get the instance in the Initial state.
  2. Idle state – The SDK is initialized and is ready to process playing information. Once Initialized, the SDK instance is not processing any data, but is listening for the play event to occur.
  3. Processing state – The SDK instance is processing playing information. The play and loadMetadata calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.
    1. playheadPosition – Call this API every one second when playhead position timer is fired. If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).
    2. stop – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.
    3. end – SDK instance exits from Processing state when this API is called.
  4. Disabled state – The SDK instance is disabled and is not processing playing information. SDK instance moves into this state in one of the following scenarios.
    1. Initialization fails
    2. appDisableApi is set to true
Note: For API Version 5.1 and above, App SDK will fire data pings and continue measurement even after the user has opted out from Nielsen measurement on a device. The data ping will be marked as opted-out ping.

Note: In case of any interruptions during playback due to alarm, calendar, call, flight mode, Wi-Fi toggle, channel change, etc., call stop to stop the measurement.

  • As soon as the playback resumes, call play, loadMetadata and playheadPosition

API Call Sequence

Use Case 1: Content has no Advertisements

Call play() with channelName JSON as below.

   "channelName": "TheMovieTitle"

Call loadMetadata() with JSON metadata for content as below.

  "type": "content",
  "assetid": "vid345-67483",
  "program": "ProgramName",
  "title": "Program S3, EP1",
  "length": "3600",

Call setPlayheadPosition() every one second until a pause / stop. Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.

Type Sample code Description
Start of stream mAppSdk.play(channelName); // channelName contains JSON metadata of channel/video name being played
mAppSdk.loadMetadata(contentMetaDataObject); // contentMetadataObject contains the JSON metadata for the content being played
Content mAppSdk.setPlayheadPosition(playheadPosition); // position is position of the playhead while the content is being played
End of Stream mAppSdk.end(); // Content playback is completed.

Use Case 2: Content has Advertisements

Call play() with channelName JSON as below.

   "channelName": "TheMovieTitle"

Call loadMetadata() with JSON metadata for ad as below.

   "type": "preroll",
   "assetid": "ad=123"
Note: In case the individual ad details are not available, send ad pod (presence) details through the loadMetadata and playhead position through playheadPosition.

Call setPlayheadPosition() every one second until a pause / stop / another loadMetadata() is called. Playhead should be passed for the entire duration of ad pod, if the ad pod details are passed as part of loadMetadata().

The sample API sequence can be used as a reference to identify the specific events that need to be called during content and ad playback.

Type Sample code Description
Start of stream mAppSdk.play(channelName); // channelName contains JSON metadata of channel/video name being played
mAppSdk.loadMetadata(contentMetaDataObject); // contentMetadataObject contains the JSON metadata for the content being played
Preroll mAppSdk.loadMetadata(prerollMetadataObject); // prerollMetadataObject contains the JSON metadata for the preroll ad
mAppSdk.setPlayheadPosition(playheadPosition); // position is position of the playhead while the preroll ad is being played
mAppSdk.stop(); // Call stop after preroll occurs
Content mAppSdk.loadMetadata(contentMetaDataObject); // contentMetadataObject contains the JSON metadata for the content being played
mAppSdk.setPlayheadPosition(playheadPosition); // position is position of the playhead while the content is being played
mAppSdk.stop(); // Call stop after the content is paused (ad starts)
Midroll mAppSdk.loadMetadata(midrollMetaDataObject); // midrollMetadataObject contains the JSON metadata for the midroll ad
mAppSdk.setPlayheadPosition(playheadPosition); // position is position of the playhead while the midroll ad is being played
mAppSdk.stop(); // App moves to background(midroll pauses)
mAppSdk.loadMetadata(midrollMetaDataObject); // App moves to foreground (midroll resumes)
mAppSdk.setPlayheadPosition(playheadPosition); // playheadPosition is position of the playhead while the midroll ad is being played
mAppSdk.stop(); // Call stop after midroll occurs
Content (End of stream) mAppSdk.loadMetadata(contentMetaDataObject); // contentMetadataObject contains the JSON metadata for the content being played
mAppSdk.setPlayheadPosition(playheadPosition); // position is position of the playhead while the content is being played
mAppSdk.stop(); // Always call stop irrespective of postroll is followed or not
End of Stream mAppSdk.end(); // Call end() at the end of content
Postroll mAppSdk.loadMetadata(postrollMetaDataObject); // postrollMetadataObject contains the JSON metadata for the postroll ad
mAppSdk.setPlayheadPosition(playheadPosition); // position is position of the playhead while the postroll ad is being played
mAppSdk.stop(); // Call stop after postroll occurs
Note: Each Ad playhead should reset or begin from 0 at ad start. When content has resumed following an ad break, playhead position must continue from where previous content segment was left off.

Sequence of Calls


Use play to pass the channel descriptor information through channelName parameter when the user taps the Play button on the player.


nielsenAppApi?.play(JSONObject channelInfo);

Objective C

   [nielsenAppApi play:(JSONObject channelInfo)];




Objective C

[nielsenApi loadMetadata:(data)];



        //Monitor the Playhead position of the AVPlayer
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -> Void in
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;
                let pos = Int64(time);
                NSLog("New Elapse Time = \(time)");

Objective C

 (void) playheadPosition: (long long) playheadPos

Sending playheadposition for content

-(void) setPlayHeadPosition {
    //Setting play head position
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){
        NSTimeInterval seconds = CMTimeGetSeconds(time);
        NSInteger intSec = seconds;
        //Sending data dictionary to SDK with updated playHead position.
        [nielsenApi playheadPosition:(intSec)];




Objective C

[nielsenApi stop];


When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).



Objective C

[nielsenApi end];

Handling Foreground and Background states

For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by Apple:

Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.

Interruptions during playback

As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:

  • Pause / Play
  • Network Loss (Wi-Fi / Airplane / Cellular)
  • Call Interrupt (SIM or Third party Skype / Hangout call)
  • Alarm Interrupt
  • Content Buffering
  • Device Lock / Unlock (Video players only, not for Audio players)
  • App going in the Background/Foreground (Video players only, not for Audio players)
  • Channel / Station Change Scenario
  • Unplugging of headphone

In case of encountering one of the above interruptions, the player application needs to

  • Call stop immediately (except when content is buffering) and withhold sending playhead position.
  • Start sending pings – 'loadMetadata' and 'playheadPosition' for the new viewing session, once the playback resumes.

Please see the Interruption Scenarios Page for more details

Pre-Certification Checklists

After the application is ready to be sent for Nielsen Certification, please go through the Digital Pre-Certification Checklist App SDK and ensure the app behaves as expected, before submitting to Nielsen.

Privacy and Opt-Out

There are three primary methods for implementing user Opt-out preferences:

  1. OS-level Opt-out - managed by Limit Ad Tracking setting on device (preferred approach).
  2. Legacy Opt-out - Direct call to SDK; used only for older versions of Nielsen iOS SDK (<
  3. App Level Opt-Out - Where Ad Framework cannot be leveraged

OS-level Opt-out

OS-level Opt-out method available on Nielsen iOS SDK Versions and above.

The Nielsen SDK automatically leverages the iOS's Limit Ad Tracking setting. The user is opted out of demographic measurement if the OS-level "Limit Ad Tracking" ("Limit Ad Tracking" for Android) setting is enabled. As a publisher, you cannot override this setting.

Legacy Opt-out

The Legacy opt-out method is only necessary for Nielsen iOS SDK versions less than

Nielsen iOS SDK and above will check for OS-level opt-out first, if available. The user will be opted out if indicated at the OS-level OR the App-level.

The legacy opt-out method works as follows:

  • Get the legacy Nielsen opt-out URL via optOutURL
  • Display a WebView element whose loadUrl is set to the value obtained from optOutURL
  • Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
    • Opt-out if the WebView URL = nielsenappsdk://1
    • Opt-in if the WebView URL = nielsenappsdk://0
  • Pass the detected URL to the userOptOut function
    • Example:
      NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out

Legacy Opt-out example code

var webView: WKWebView!
var NIELSEN_URL_OPT_OUT : String = "nielsenappsdk://1"
var NIELSEN_URL_OPT_IN : String = "nielsenappsdk://0"

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {

       let urlStr = navigationAction.request.url?.absoluteString

        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){
            let appApi = self.nielsenApi


Retrieve current Opt-Out preference

Whether the user is opted out viaOS-level Opt-out or via App-level Opt-out, the current Opt-Out status as detected by the SDK is available via the optOutStatus property in the Nielsen SDK API

Required Privacy Links

Users must either have access to the "About Nielsen Measurement" page, or have similar text available within the native app. Include "About Nielsen Measurement" and "Your Choices" link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.

In addition, the following text must be included in your app store description.

"Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see http://priv-policy.imrworldwide.com/priv/mobile/us/en/optout.html for more information"

Webview Example

The below code is an example of displaying the Nielsen Privacy page to the user.

import UIKit
import WebKit
import NielsenAppApi

class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
    var webView: WKWebView!
    var nielsenApi: NielsenAppApi!
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    override func viewDidLoad() {
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: "new_ios_bg.png")!) 
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)
        if let appApi = self.nielsenApi {
            //Getting the optPut URL from SDK
            if let url = URL(string: appApi.optOutURL) {
                webView.load(URLRequest(url: url))
                webView.allowsBackForwardNavigationGestures = true

App Level Opt Out

This is only used if the Ad Framework is not available. The Opt-Out occurs by opening a Nielsen-defined web page and passing the user choice from the 'WebView'. In order to do this, the application needs to:

  • Implement the UIWebView delegate method to open the Nielsen Privacy web page
  • Capture user's selection
  • Pass the selection back to the SDK via the userOptOut.

Capture and forward user selection

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    NSString *command = [NSString stringWithFormat:@"%@",request.URL];
    if ([command isEqualToString:kNielsenWebClose]) {
        // Close the WebView
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];
        return NO;
    // Retrieve next URL if it’s not opt-in/out selection
    return (![nAppApiObject userOptOut:command]);
  • The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes userOptOut with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.
    • [nAppApiObject userOptOut:command] passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.
Note: When 'WebView' is closed, pass the status returned from 'WebView' to the SDK within the app. The App SDK manages the user's choice (Opt-Out / Opt-In), the app does not need to manage this status.


To implement OTT measurement, report OTT changes to the SDK using public API interface: updateOTT

In order to detect AirPlay and mirroring changes we use AVAudioSessionPortDescription properties that are different on different iOS versions. We found that on iOS versions 8 - 10 AVAudioSessionPortDescription has the following values:
AirPlay: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-airplay
Mirroring: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-screen

For iOS 11+ some parameters like name and UID have different values:
AirPlay: type = AirPlay; name = AirPlay; UID = 0eb63aae-5915-45f1-b0f7-0102a0e50d53
Mirroring: type = AirPlay; name = Apple TV 4K; UID = 4335E8A9-1C0A-4251-9000-28CA5FA2F3CF-192731714653291-screen

To implement OTT measurement, report OTT changes to the SDK using public API interface: updateOTT
The following code snipped is suggested for AirPlay / mirroring detection on iOS devices.



Subscribe to AVAudioSessionRouteChangeNotification

NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChanged(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)

Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:

func handleRouteChanged(_ notification: Notification) {
var currentStatus: [String: String] = ["ottStatus": "0"]

let session = AVAudioSession.sharedInstance()
let currentRoute = session.currentRoute
for outputPort in currentRoute.outputs {
if outputPort.portType == AVAudioSessionPortAirPlay {
currentStatus["ottStatus"] = "1"
currentStatus["ottDeviceModel"] = outputPort.portName
currentStatus["ottDeviceID"] = outputPort.uid

if outputPort.portName == "AirPlay" {
currentStatus["ottDevice"] = "airplay"
currentStatus["ottType"] = "airplay"
else {
if outputPort.portName.contains("Apple TV") {
currentStatus["ottDevice"] = "appleTV"
else {
currentStatus["ottDevice"] = "other"

if outputPort.uid.hasSuffix("airplay") {
currentStatus["ottType"] = "airplay"
else if outputPort.uid.hasSuffix("screen") {
currentStatus["ottType"] = "mirroring"
else {
currentStatus["ottType"] = "other"

// report OTT status update to Nielsen SDK

Report OTT update to the Nielsen SDK

func reportOTTUpdate(_ ottDict: [String: String]) {
if let nielsenSdk = self.nielsenAppApi {

Objective C


Subscribe to AVAudioSessionRouteChangeNotification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];

Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:

- (void)handleRouteChanged:(NSNotification *)notification
NSMutableDictionary *ottDict = [NSMutableDictionary dictionaryWithDictionary: @{@"ottStatus": @"0"}];

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs) {
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]) {
ottDict[@"ottStatus"] = @"1";
ottDict[@"ottDeviceModel"] = outputPort.portName;
ottDict[@"ottDeviceID"] = outputPort.UID;

if ([outputPort.portName isEqualToString:@"AirPlay"]) {
ottDict[@"ottDevice"] = @"airplay";
ottDict[@"ottType"] = @"airplay";
else {
if ([outputPort.portName containsString:@"Apple TV"]) {
ottDict[@"ottDevice"] = @"appleTV";
else {
ottDict[@"ottDevice"] = @"other";

if ([outputPort.UID hasSuffix:@"airplay"]) {
ottDict[@"ottType"] = @"airplay";
else if ([outputPort.UID hasSuffix:@"screen"]) {
ottDict[@"ottType"] = @"mirroring";
else {
ottDict[@"ottType"] = @"other";

// report OTT status update to Nielsen SDK
[self reportOTTWithDict:ottDict];

Report OTT update to the Nielsen SDK

- (void)reportOTTWithDict:(NSDictionary *)ottDict
[self.nielsenSDK updateOTT:ottDict];

Going Live

Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.

  1. Debug Logging: Disable logging by deleting {nol_sdkDebug: 'DEBUG'} from initialization call.

Note: before going live you have to inform Nielsen team - this is necessary, because Nielsen team has to adjust internal configuration parameter to enable data collection. Without that notification no data will be collected and no data will be reported.

Removing Simulators

Simulator slices are needed to let clients build and debug their app on the simulators, but they should be removed before sending the app to the AppStore. Here is an example Shell script that could be added as a Run Script phase in the application.


# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)


for ARCH in $ARCHS

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"


Sample Applications

The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories: