<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nielsentest.mywikis.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=WilsonQuispe</id>
	<title>Engineering Client Portal - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://nielsentest.mywikis.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=WilsonQuispe"/>
	<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/wiki/Special:Contributions/WilsonQuispe"/>
	<updated>2026-04-05T20:14:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Ireland_Video_Android_SDK&amp;diff=6545</id>
		<title>DCR Ireland Video Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Ireland_Video_Android_SDK&amp;diff=6545"/>
		<updated>2023-10-11T09:19:31Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Create Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The Nielsen SDK is one of the multiple framework SDKs that Nielsen provides to enable measuring linear (live) and on-demand TV viewing using TVs, mobile devices, etc.&lt;br /&gt;
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  It supports a variety of Nielsen Measurement Products like Digital in TV Ratings ([[DCR &amp;amp; DTVR|DTVR]]), Digital Content Ratings ([[DCR &amp;amp; DTVR|DCR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a subsection/page in the application.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This ''SDK Android integration guide'' is applicable for '''Android TV''' as well.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 30px;&amp;quot; |&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-style=&amp;quot;background-color:#d0f6f8;&amp;quot;&lt;br /&gt;
|| ☑ || &amp;quot;App ID (appid)&amp;quot; || Unique ID assigned to the player/site and configured by product. || Contact Nielsen&lt;br /&gt;
|-style=&amp;quot;background-color:#d0f6f8;&amp;quot;&lt;br /&gt;
|| ☑ || &amp;quot;Nielsen SDK&amp;quot; || Includes SDK frameworks and &amp;quot;sample implementation&amp;quot;; &amp;quot;See [[Android SDK Release Notes]]&amp;quot; || [[Special:Downloads|Download]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
The Nielsen Android SDK comes in three flavors.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! SDK Flavor&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| '''Android Ad Version'''&lt;br /&gt;
|* Opt-In and Opt-Out functionality managed by Opt out of Ads Personalization setting on device. &amp;lt;br /&amp;gt;* The Nielsen SDK will collect the [https://developer.android.com/training/articles/ad-id Google Advertising ID] unless the user Opts out.&amp;lt;br&amp;gt;* If the Google Play Service is unavailable, (ie: Amazon and Huawei devices) the Nielsen SDK will secure the Android ID.&amp;lt;br&amp;gt; * There are 3 versions available starting with the Nielsen SDK 8.1.0.0.&lt;br /&gt;
|-&lt;br /&gt;
| '''Android No Ad Framework'''&lt;br /&gt;
|* Without the Google Play Services SDK, the Nielsen SDK cannot read the Google Advertising ID, so will retrieve the Android ID.&amp;lt;br /&amp;gt;* The Android ID is a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user and device.&amp;lt;br /&amp;gt;* The developer is required to present the User Choice Opt-Out page which is described in the [[#Global_Android_SDK_No_Ad_Framework_Opt-out|Global Android SDK No Ad Framework Opt-out]].&lt;br /&gt;
|-&lt;br /&gt;
| '''Android SDK noID'''&lt;br /&gt;
|* This version of the Nielsen SDK is perfect for Kid apps, or where no ID is required.&amp;lt;br&amp;gt;* For the requirement, please review the [[#Global_Android_SDK_No_ID_Opt-out|Global Android SDK No ID Opt-out]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For Video player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== Create SDK Instance ==&lt;br /&gt;
The latest version of the Nielsen App SDK allows instantiating multiple instances of the SDK object when needed, which can then be used simultaneously. '''For the general use case where only one video is played at the same time in the App, a single instance of SDK object can then be used to play back and measure all watched streams one after another.'''&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required/Obligatory? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || &amp;quot;PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used || Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;ire&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1) [[AppSDK()|AppSDK()]] is no longer a singleton object and should be created as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
try{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;sfcode&amp;quot;, &amp;quot;ire&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds &lt;br /&gt;
&lt;br /&gt;
         // Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
         mAppSdk = new AppSdk(appContext, appSdkConfig, this);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e){&lt;br /&gt;
         Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
2) implement IAppNotifier into your activity like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public class MainActivity extends AppCompatActivity implements IAppNotifier&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
3) implement callback&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;@Override&lt;br /&gt;
public void onAppSdkEvent(long timestamp, int code, String description){&lt;br /&gt;
  Log.d(TAG, &amp;quot;SDK callback onAppSdkEvent &amp;quot; + description);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So whole Activity will look like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
package com.example.josefvancura.nlsdemotmp;&lt;br /&gt;
&lt;br /&gt;
import android.content.Context;&lt;br /&gt;
import android.support.v7.app.AppCompatActivity;&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import android.util.Log;&lt;br /&gt;
&lt;br /&gt;
import com.nielsen.app.sdk.*;&lt;br /&gt;
&lt;br /&gt;
import org.json.JSONException;&lt;br /&gt;
import org.json.JSONObject;&lt;br /&gt;
&lt;br /&gt;
public class MainActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    private AppSdk mAppSdk = null;&lt;br /&gt;
    private String TAG = &amp;quot;MainActivity&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_main);&lt;br /&gt;
&lt;br /&gt;
        Context context = getApplicationContext();&lt;br /&gt;
&lt;br /&gt;
        try{&lt;br /&gt;
            // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
            JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
                    .put(&amp;quot;appid&amp;quot;, &amp;quot;PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;)&lt;br /&gt;
                    .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
                    .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
                    .put(&amp;quot;sfcode&amp;quot;, &amp;quot;ire&amp;quot;)&lt;br /&gt;
                    .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
            // Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
            mAppSdk = new AppSdk(context, appSdkConfig, this ); // Notifier - activity implements IAppNotifier, callback in onAppSdkEvent()&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
        catch (JSONException e){&lt;br /&gt;
            Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onAppSdkEvent(long timestamp, int code, String description) {&lt;br /&gt;
        Log.d(TAG, &amp;quot;SDK callback onAppSdkEvent &amp;quot; + description);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== APP SDK Error &amp;amp; Event Codes ====&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
==== Life cycle of SDK instance ====&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 &amp;quot;&amp;quot;Initial state&amp;quot;&amp;quot;.&lt;br /&gt;
# '''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.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. API calls &amp;quot;play&amp;quot; and &amp;quot;loadMetadata&amp;quot; move the SDK instance into this state. In this state, the SDK instance will be able to process the API calls (see below)&lt;br /&gt;
# '''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.&lt;br /&gt;
## Initialization fails&lt;br /&gt;
## &amp;lt;code&amp;gt;appDisableApi&amp;lt;/code&amp;gt; is called&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@property (assign) BOOL appDisableApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
The parameters passed must be either a JSON formatted string. The JSON passed in the SDK must be well-formed.&lt;br /&gt;
&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Variable Names like appid, appname, dataSrc, title, type etc. are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create channelName Metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream	|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Create Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of episode (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For VoD video length) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || the airdate in the linear TV || YYYYMMDD HH24:MI:SS || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment for the clients granular reporting within a brand&lt;br /&gt;
|| Example: ChannelName&lt;br /&gt;
|| Optional&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment for the clients granular reporting within a brand&lt;br /&gt;
|| Example: PlayerName&lt;br /&gt;
|| Optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Create Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' All metadata values should be passed as UTF-8 strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; URL Character Limit: There is a URL character limit of 2K characters due to browser limitations. Exceeding this value could impair data delivery on particular browsers. &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== MetaData Example ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelName&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;segB&amp;quot;, &amp;quot;ChannelName&amp;quot;) //optional&lt;br /&gt;
    .put(&amp;quot;segC&amp;quot;, &amp;quot;PlayerName&amp;quot;) //optional&lt;br /&gt;
&lt;br /&gt;
JSONObject adMetadata = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;postroll&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;AD-ID123&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start the Measurement ==&lt;br /&gt;
&lt;br /&gt;
=== Overview of SDK API Calls ===&lt;br /&gt;
&lt;br /&gt;
==== play ====&lt;br /&gt;
The play method prepares the SDK for reporting once an asset has loaded and playback has begun. Use play to pass the channel descriptor information through channelName parameter when the user taps the &amp;quot;&amp;quot;Play&amp;quot;&amp;quot; button on the player. Call play only when initially starting the video.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;mAppSdk.play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== loadMetadata ====&lt;br /&gt;
Needs to be called at the beginning of each asset, pass JSON object for relevant content or ad. Make sure to pass as 1st loadMetadata for content at the begining of playlist - see below API call sequence examples.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;mAppSdk.loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== playheadPosition ====&lt;br /&gt;
Pass playhead position every second during playback. for VOD: pass current position in seconds. for Live: current Unix timestamp (seconds since Jan-1-1970 UTC) - if it is possible to seek back in Live content, then pass related Unix time (not current). Pass whole number that increments only by 1 like 1,2,3..&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Java&amp;quot;&amp;gt;mAppSdk.setPlayheadPosition(long videoPositon);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== stop ====&lt;br /&gt;
Call when&lt;br /&gt;
* ads complete playing&lt;br /&gt;
* when a user pauses playback&lt;br /&gt;
* upon any user interruption scenario - see bellow chapter Interruption scenario&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;mAppSdk.stop();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== end ====&lt;br /&gt;
Call when the content asset completes playback.  Stops measurement progress.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;mAppSdk.end();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Ads ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[setPlayheadPosition()]] every one second until a pause.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| Resume Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Ads ====&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad-123&amp;quot;&lt;br /&gt;
   ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[setPlayheadPosition()]] every one second until a pause / 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(channelInfo); &amp;lt;/code&amp;gt; || // channelName contains JSON metadata of channel name being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Stop/Resume the Measurement for video Playback Interruptions ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt; immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Once the playback resumes, start sending pings &amp;lt;code&amp;gt;playheadPosition&amp;lt;/code&amp;gt; for the new viewing session.&lt;br /&gt;
Please see the [[Digital Measurement FAQ]] for more details&lt;br /&gt;
&lt;br /&gt;
== Review SDK Integration Architecture Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== For Content Playback ===&lt;br /&gt;
&lt;br /&gt;
[[File:nlsn-sdk-achitecture-diagram-content-v1.png||SDK Integration Architecture Diagram - Content]]&lt;br /&gt;
&lt;br /&gt;
=== For Ad Playback ===&lt;br /&gt;
[[File:nlsn-sdk-achitecture-diagram-ad-v1.png||SDK Integration Architecture Diagram - Ad]]&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
=== Global Android SDK No ID Opt-out ===&lt;br /&gt;
&lt;br /&gt;
#  Ensure that you are using the No ID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt-out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required Privacy Links ===&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
'''&amp;quot;Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=en-ie for more information&amp;quot;&lt;br /&gt;
(There is also a version in Irish available: https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=ga )'''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional Step for DCR Chromecast Android SDK ==&lt;br /&gt;
For the implementation of Chromecast SDK architecture. Please refer to this guide: [https://engineeringportal.nielsen.com/docs/DCR_Chromecast_Android_SDK DCR Chromecast Android SDK]&lt;br /&gt;
&lt;br /&gt;
== Test your player by yourself ==&lt;br /&gt;
=== Guide ===&lt;br /&gt;
1. Connect your PC and test device (tablet or phone) via same router.&amp;lt;br /&amp;gt;&lt;br /&gt;
2. PC side: run Proxy sw (like Charles) and get local IP&amp;lt;br /&amp;gt;&lt;br /&gt;
3. Test device: modify Wifi setting to pass through Proxy IP from step 2.&amp;lt;br /&amp;gt;&lt;br /&gt;
4. Test device: run your player, launch video&amp;lt;br /&amp;gt;&lt;br /&gt;
5. PC side: filter traffic by &amp;quot;nmrodam&amp;quot; and confirm presence of SDK pings&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example of SDK ping (https call) ===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://secure-ire.nmrodam.com/cgi-bin/gn?prd=dcr&amp;amp;ci=se-910684&amp;amp;ch=se-910684_c01_P&amp;amp;asn=defChnAsset&amp;amp;fp_id=096ohdsc0jqkmct81qpxhmn19qx041630053963&amp;amp;fp_cr_tm=1630053963&amp;amp;fp_acc_tm=1630053963&amp;amp;fp_emm_tm=1630053963&amp;amp;ve_id=afc5d61a88b62672&amp;amp;sessionId=zc6gh3uhka7d2mtobb2b2m7sixygy1630053963&amp;amp;tl=Djuren%20p%C3%A5%20Djuris&amp;amp;prv=1&amp;amp;c6=vc,c01&amp;amp;ca=se-910684_c01_218531&amp;amp;cg=Hemligheter&amp;amp;c13=asid,T1194003B-797F-4896-A5C0-05914236146E&amp;amp;c32=segA,NA&amp;amp;c33=segB,NA&amp;amp;c34=segC,NA&amp;amp;c15=apn,&amp;amp;plugv=4.4.1&amp;amp;playerv=ExoPlayer&amp;amp;sup=1&amp;amp;segment2=&amp;amp;segment1=&amp;amp;forward=0&amp;amp;ad=1&amp;amp;cr=4_00_99_D1_10000&amp;amp;c9=devid,c041ec5e50722cdf8cc5b4826c24ae54c5747a6570e900006c826b37ca01ce17&amp;amp;enc=true&amp;amp;c1=nuid,c041ec5e50722cdf8cc5b4826c24ae54c5747a6570e900006c826b37ca01ce17&amp;amp;at=timer&amp;amp;rt=video&amp;amp;c16=sdkv,aa.8.1.0&amp;amp;c27=cln,34&amp;amp;crs=0&amp;amp;lat=&amp;amp;lon=&amp;amp;c29=plid,16300539624283525&amp;amp;c30=bldv,aa.8.1.0.0_gaxnons&amp;amp;st=dcr&amp;amp;c7=osgrp,&amp;amp;c8=devgrp,&amp;amp;c10=plt,&amp;amp;c40=adbid,&amp;amp;c14=osver,ANDROID.11&amp;amp;c26=dmap,1&amp;amp;dd=&amp;amp;hrd=&amp;amp;wkd=&amp;amp;c35=adrsid,&amp;amp;c36=cref1,&amp;amp;c37=cref2,&amp;amp;c11=agg,1&amp;amp;c12=apv,4.4.1.4004001&amp;amp;c51=adl,0&amp;amp;c52=noad,0&amp;amp;sd=578&amp;amp;pc=NA&amp;amp;c53=fef,n&amp;amp;c54=oad,&amp;amp;c55=cref3,&amp;amp;c57=adldf,2&amp;amp;ai=218531&amp;amp;c3=st,c&amp;amp;c64=starttm,1630053962&amp;amp;adid=218531&amp;amp;c58=isLive,false&amp;amp;c59=sesid,257f8bz854wmqa31gk3icyi7cmj131630053964&amp;amp;c61=createtm,1630053997&amp;amp;c63=pipMode,&amp;amp;ci_userid=&amp;amp;is_auto_play=no&amp;amp;pl_title=&amp;amp;is_prem=no&amp;amp;is_prog=&amp;amp;ad_origin=&amp;amp;adidx=&amp;amp;is_tpad=&amp;amp;ci_passthr=&amp;amp;c62=sendTime,1630053997&amp;amp;c68=bndlid,air.se.urplay.android_player.debug&amp;amp;nodeTM=&amp;amp;logTM=&amp;amp;c73=phtype,&amp;amp;c74=dvcnm,&amp;amp;c76=adbsnid,&amp;amp;c77=adsuprt,2&amp;amp;uoo=&amp;amp;evdata=PL%3A1630053964727%3A0&amp;amp;c71=ottflg,0&amp;amp;c72=otttyp,&amp;amp;c44=progen,&amp;amp;davty=1&amp;amp;si=&amp;amp;c66=mediaurl,&amp;amp;sdd=retry,0~~retryreason,~~devmodel,SM-G981B~~devtypid,samsung-SM-G981B~~sysname,Android~~sysversion,11~~manuf,samsung&amp;amp;cat_id=3398d8e4-e613-42c1-92aa-1a6fc52dcf5c&amp;amp;vtoff=0&amp;amp;rnd=1630053997971&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 9 :  Provide your app for certification ==&lt;br /&gt;
Once ready please send your application to Nielsen local staff for certification.&lt;br /&gt;
&lt;br /&gt;
== Step 10 :  Going Live ==&lt;br /&gt;
After the integration has been certified by Nielsen (but not prior to that), do the following:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Ireland_Video_iOS_SDK&amp;diff=6544</id>
		<title>DCR Ireland Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Ireland_Video_iOS_SDK&amp;diff=6544"/>
		<updated>2023-10-11T09:18:48Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Create Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The Nielsen SDK is one of the multiple framework SDKs that Nielsen provides to enable measuring linear (live) and on-demand TV viewing using TVs, mobile devices, etc.&lt;br /&gt;
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 Content Ratings (DCR), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
{{iOS_SpecialNotes_for_iOS14}}&lt;br /&gt;
&lt;br /&gt;
{{iOS_Prerequisites_and_Implementation_Overview}}&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== Create SDK Instance ==&lt;br /&gt;
The latest version of the Nielsen App SDK allows instantiating multiple instances of the SDK object when needed, which can then be used simultaneously. '''For the general use case where only one video is played at the same time in the App, a single instance of SDK object can then be used to play back and measure all watched streams one after another.'''&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required/Obligatory? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || &amp;quot;PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used || Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;ire&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string.&lt;br /&gt;
&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': DO NOT activate the Debug flag in a production environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sample SDK Initialization Code ====&lt;br /&gt;
&lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Using Objective-C=====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    NSDictionary *appInformation = @{&lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;app name here&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;ire&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDeligate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Using Swift =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit: NSObject {&lt;br /&gt;
    class func createNielsenAppApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
    let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;app name here&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;ire&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]&lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sample code using AVPlayer.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
&lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
        self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
        NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== APP SDK Error &amp;amp; Event Codes ====&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
==== Life cycle of SDK instance ====&lt;br /&gt;
The life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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'''.&lt;br /&gt;
# '''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.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. API calls &amp;quot;play&amp;quot; and &amp;quot;loadMetadata&amp;quot; move the SDK instance into this state. In this state, the SDK instance will be able to process the API calls (see below)&lt;br /&gt;
# '''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.&lt;br /&gt;
## Initialization fails&lt;br /&gt;
## &amp;lt;code&amp;gt;appDisableApi&amp;lt;/code&amp;gt; is called&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@property (assign) BOOL appDisableApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
The parameters passed must be either a JSON formatted NSString or a NSDictionary object. The JSON passed in the SDK must be well-formed.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Variable Names like appid, appname, dataSrc, title, type etc. are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create channelName Metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream	|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Create Content Metadata ===&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of episode (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For VoD video length) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || the airdate in the linear TV || YYYYMMDD HH24:MI:SS || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment for the clients granular reporting within a brand&lt;br /&gt;
|| Example: ChannelName&lt;br /&gt;
|| Optional&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment for the clients granular reporting within a brand&lt;br /&gt;
|| Example: PlayerName&lt;br /&gt;
|| Optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Create Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' All metadata values should be passed as UTF-8 strings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; URL Character Limit: There is a URL character limit of 2K characters due to browser limitations. Exceeding this value could impair data delivery on particular browsers. &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== MetaData Example ===&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
    @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NSDictionary *contentMetadata = @&lt;br /&gt;
  {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
    @ &amp;quot;segB&amp;quot;: @ &amp;quot;ChannelName&amp;quot;, //optional&lt;br /&gt;
    @ &amp;quot;segC&amp;quot;: @ &amp;quot;PlayerName&amp;quot; //optional&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary *adMetadata = @&lt;br /&gt;
  {&lt;br /&gt;
    @&amp;quot;type&amp;quot; : &amp;quot;postroll&amp;quot;,&lt;br /&gt;
    @&amp;quot;assetid&amp;quot; : &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
     let channelInfo = [&lt;br /&gt;
        &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
     ]&lt;br /&gt;
&lt;br /&gt;
     let contentMetadata = [&lt;br /&gt;
         &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
         &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
         &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
         &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
         &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
         &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
         &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
         &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
         &amp;quot;segB&amp;quot;: &amp;quot;ChannelName&amp;quot;, //optional&lt;br /&gt;
         &amp;quot;segC&amp;quot;: &amp;quot;PlayerName&amp;quot; //optional&lt;br /&gt;
     ]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    let adMetadata = [&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
        &amp;quot;assetid&amp;quot; : &amp;quot;ad123&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start the Measurement ==&lt;br /&gt;
&lt;br /&gt;
=== Overview of SDK API Calls ===&lt;br /&gt;
&lt;br /&gt;
==== play ====&lt;br /&gt;
The play method prepares the SDK for reporting once an asset has loaded and playback has begun. Use play to pass the channel descriptor information through channelName parameter when the user taps the '''Play''' button on the player. Call play only when initially starting the video.&lt;br /&gt;
===== Using Objective-C =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[self.nielsenAppApi play:channelInfo];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===== Using Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.play(channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== loadMetadata ====&lt;br /&gt;
Needs to be called at the beginning of each asset, pass JSON object for relevant content or ad. Make sure to pass as 1st loadMetadata for content at the begining of playlist - see below API call sequence examples.&lt;br /&gt;
===== Using Objective-C =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[self.nielsenAppApi loadMetadata:metadataDict];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===== Using Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(metadataDict)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== playheadPosition ====&lt;br /&gt;
Pass playhead position every second during playback. for VOD: pass current position in seconds. for Live: current Unix timestamp (seconds since Jan-1-1970 UTC) - if it is possible to seek back in Live content, then pass related Unix time (not current). Pass whole number that increments only by 1 like 1,2,3..&lt;br /&gt;
===== Using Objective-C =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
[self.nielsenAppApi playheadPosition:pos];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===== Using Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== stop ====&lt;br /&gt;
Call when&lt;br /&gt;
* ads complete playing&lt;br /&gt;
* when a user pauses playback&lt;br /&gt;
* upon any user interruption scenario - see bellow chapter Interruption scenario&lt;br /&gt;
===== Using Objective-C =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[self.nielsenAppApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===== Using Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.stop;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== end ====&lt;br /&gt;
Call when the content asset completes playback.  Stops measurement progress.&lt;br /&gt;
===== Using Objective-C =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[self.nielsenAppApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===== Using Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Ads ====&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;ChannelName&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(channelName); &amp;lt;/code&amp;gt; || // channelName contains JSON metadata of channel/video name being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Ads ====&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;ChannelName&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad_123&amp;quot;,&lt;br /&gt;
   ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(channelName); &amp;lt;/code&amp;gt; || // channelName contains JSON metadata of channel/video name being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Stop/Resume the Measurement for video Playback Interruptions ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third-party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt; immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Once the playback resumes, start sending pings &amp;lt;code&amp;gt;playheadPosition&amp;lt;/code&amp;gt; for the new viewing session.&lt;br /&gt;
Please see the [[Digital Measurement FAQ]] for more details&lt;br /&gt;
&lt;br /&gt;
== Review SDK Integration Architecture Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== For Content Playback ===&lt;br /&gt;
&lt;br /&gt;
[[File:nlsn-sdk-achitecture-diagram-content-v1.png||SDK Integration Architecture Diagram - Content]]&lt;br /&gt;
&lt;br /&gt;
=== For Ad Playback ===&lt;br /&gt;
[[File:nlsn-sdk-achitecture-diagram-ad-v1.png||SDK Integration Architecture Diagram - Ad]]&lt;br /&gt;
&lt;br /&gt;
{{iOS_NoID_Privacy_and_Opt-Out}}&lt;br /&gt;
&lt;br /&gt;
{{iOS_Airplay}}&lt;br /&gt;
== Test your player by yourself ==&lt;br /&gt;
=== Guide ===&lt;br /&gt;
1. Connect your PC and test device (tablet or phone) via same router.&amp;lt;br /&amp;gt;&lt;br /&gt;
2. PC side: run Proxy sw (like Charles) and get local IP&amp;lt;br /&amp;gt;&lt;br /&gt;
3. Test device: modify Wifi setting to pass through Proxy IP from step 2.&amp;lt;br /&amp;gt;&lt;br /&gt;
4. Test device: run your player, launch video&amp;lt;br /&amp;gt;&lt;br /&gt;
5. PC side: filter traffic by &amp;quot;nmrodam&amp;quot; and confirm presence of SDK pings&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example of SDK ping (https call) ===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://secure-ire.nmrodam.com/cgi-bin/gn?prd=dcr&amp;amp;ci=se-910685&amp;amp;ch=se-910685_c01_P&amp;amp;asn=defChnAsset&amp;amp;fp_id=a2nfmy17lyvkhlxqstvmgypqly90m1629966210&amp;amp;fp_cr_tm=1629966210&amp;amp;fp_acc_tm=1629966210&amp;amp;fp_emm_tm=1629966210&amp;amp;ve_id=20A7CFD5-9860-4256-A6CE-45C251F4C243&amp;amp;sessionId=yvx0rtsxydmaxueji8zgfzj0f2f1w1629966209&amp;amp;tl=&amp;amp;prv=1&amp;amp;c6=vc,c01&amp;amp;ca=se-910685_c01_51HERB1501&amp;amp;cg=Play%20%3E%20Webbtv%20%3E%20Nyheter&amp;amp;c13=asid,P3D8D326A-2DBC-486A-8FD8-9AF4452B2A41&amp;amp;c32=segA,NA&amp;amp;c33=segB,NA&amp;amp;c34=segC,NA&amp;amp;c15=apn,Aftonbladet&amp;amp;plugv=&amp;amp;playerv=&amp;amp;sup=1&amp;amp;segment2=&amp;amp;segment1=&amp;amp;forward=0&amp;amp;ad=1&amp;amp;cr=4_00_99_D1_00000&amp;amp;c9=devid,12b9377cbe7e5c94e8a70d9d23929523d14afa954793130f8a3959c7b849aca8&amp;amp;enc=true&amp;amp;c1=nuid,12b9377cbe7e5c94e8a70d9d23929523d14afa954793130f8a3959c7b849aca8&amp;amp;at=timer&amp;amp;rt=video&amp;amp;c16=sdkv,ai.8.1.0&amp;amp;c27=cln,15&amp;amp;crs=&amp;amp;lat=&amp;amp;lon=&amp;amp;c29=plid,16299662096458868&amp;amp;c30=bldv,ai.8.1.0.0_gsxaoni&amp;amp;st=dcr&amp;amp;c7=osgrp,&amp;amp;c8=devgrp,&amp;amp;c10=plt,&amp;amp;c40=adbid,&amp;amp;c14=osver,iOS14.6&amp;amp;c26=dmap,1&amp;amp;dd=&amp;amp;hrd=&amp;amp;wkd=&amp;amp;c35=adrsid,&amp;amp;c36=cref1,&amp;amp;c37=cref2,&amp;amp;c11=agg,1&amp;amp;c12=apv,5.47.83.0.25245&amp;amp;c51=adl,15&amp;amp;c52=noad,1&amp;amp;sd=15&amp;amp;pc=NA&amp;amp;c53=fef,n&amp;amp;c54=oad,&amp;amp;c55=cref3,&amp;amp;c57=adldf,2&amp;amp;ai=51HERB1501&amp;amp;c3=st,a&amp;amp;c64=starttm,1629966240&amp;amp;adid=51HERB1501&amp;amp;c58=isLive,false&amp;amp;c59=sesid,iqal6k21r0de8gm901kif5xznar7q1629966240&amp;amp;c61=createtm,1629966255&amp;amp;c63=pipMode,&amp;amp;ci_userid=&amp;amp;is_auto_play=&amp;amp;pl_title=&amp;amp;is_prem=&amp;amp;is_prog=&amp;amp;ad_origin=&amp;amp;adidx=1%2F1&amp;amp;is_tpad=&amp;amp;ci_passthr=&amp;amp;c62=sendTime,1629966255&amp;amp;c68=bndlid,se.aftonbladet.Aftonbladet&amp;amp;c69=cvw,&amp;amp;nodeTM=&amp;amp;logTM=&amp;amp;c73=phtype,&amp;amp;c74=dvcnm,&amp;amp;c76=adbsnid,&amp;amp;uoo=&amp;amp;c44=progen,&amp;amp;davty=1&amp;amp;si=&amp;amp;c66=mediaurl,&amp;amp;sdd=retry,0~~retryreason,~~devmodel,iPhone9%2C4~~devtypid,iPhone9%2C4~~sysname,iOS~~sysversion,14.6~~manuf,Apple&amp;amp;cat_id=a6f7fb13-8801-484c-9692-6db6dfb470aa&amp;amp;vtoff=0&amp;amp;rnd=1629966255319&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Provide your app for certification ==&lt;br /&gt;
Once ready please send your application to Nielsen local staff for certification.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6536</id>
		<title>DCR Poland Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6536"/>
		<updated>2023-09-28T11:15:24Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 30px;&amp;quot; |&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''sfcode''' || Environment that the SDK must point to || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ DCR_and_DTVR_with_iOS17_or_TVOS17|Nielsen Digital Measurement and iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
&lt;br /&gt;
* The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Optional; automatically detected in SDK 6.0.0.4 and above || Nielsen Sample App&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
* &amp;quot;pl&amp;quot; &lt;br /&gt;
|| Nielsen-specified || Yes || pl&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;INFO&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': DO NOT activate the Debug flag in a production environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift  = &lt;br /&gt;
Swift 4.0 Example:&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample code using AVPlayer.&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NielsenInit.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NielsenInit&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate&lt;br /&gt;
{    &lt;br /&gt;
    NSDictionary *appInformation = @{ @&amp;quot;appid&amp;quot;: @&amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                            @&amp;quot;appversion&amp;quot;: @&amp;quot;1.0&amp;quot;,&lt;br /&gt;
                            @&amp;quot;sfcode&amp;quot;: @&amp;quot;pl&amp;quot;,&lt;br /&gt;
                            @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;, };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NielsenInit.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NielsenInit : NSObject&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sample Code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Payload ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** 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.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
    &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;C77664&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Program S2, E3&amp;quot;,&lt;br /&gt;
    &amp;quot;isfullepisode&amp;quot;: &amp;quot;Yes&amp;quot;,&lt;br /&gt;
    &amp;quot;program&amp;quot;: &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
    &amp;quot;airdate&amp;quot;: &amp;quot;20171020 10:05:00&amp;quot;,&lt;br /&gt;
    &amp;quot;adloadtype&amp;quot;: &amp;quot;2&amp;quot;,&lt;br /&gt;
    &amp;quot;segB&amp;quot;: &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
    &amp;quot;segC&amp;quot;: &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * channelInfo = @ {&lt;br /&gt;
    @ &amp;quot;channelName&amp;quot;: @ &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
        @ &amp;quot;assetid&amp;quot;: @ &amp;quot;C77664&amp;quot;,&lt;br /&gt;
        @ &amp;quot;title&amp;quot;: @ &amp;quot;S2,E3&amp;quot;,&lt;br /&gt;
        @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
        @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
        @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
        @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20180120 10:00:00&amp;quot;,&lt;br /&gt;
        @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;,&lt;br /&gt;
        @ &amp;quot;segB&amp;quot;: @ &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
        @ &amp;quot;segC&amp;quot;: @ &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== ChannelName metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode / clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type || type of asset	|| &amp;quot;content&amp;quot; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| unique ID assigned to asset (max 64 characters; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) || custom (no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| (string) name of program (max 254 characters)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| (string) episode title (max 254 characters)	|| custom - no backslash allowed in string (because of 3rd party data processing) || ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| (int) length of content in seconds	|| 86400 seconds for live stream. For Event-Livestreams planned length. For VoD video length||	✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear TV. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;	||	YYYY-MM-DDTHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS+xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS-xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDD HH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
MM-DD-YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
MM/DD/YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
 (pass beginning of epoch if unknown)&lt;br /&gt;
	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag	||	&amp;quot;y&amp;quot;- full episode, &amp;quot;n&amp;quot;- non full episode	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads ||  ✓&lt;br /&gt;
|-&lt;br /&gt;
| progen || program genre	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| crossId1 || standard episode ID	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| clientid	|| &lt;br /&gt;
parent ID – value is automatically populated through provided AppID.&amp;lt;br/&amp;gt;&lt;br /&gt;
In order to override the brand configured to the AppID, pass parent &amp;lt;br/&amp;gt;&lt;br /&gt;
value here and the sub-brand ID associated to that brand in the subbrand &amp;lt;br/&amp;gt;&lt;br /&gt;
key (e.g. multiple brands in App)	&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen	&lt;br /&gt;
||&lt;br /&gt;
|-&lt;br /&gt;
| subbrand	|| vcid/sub-brand ID – value is automatically populated through provided&amp;lt;br/&amp;gt;&lt;br /&gt;
AppID. In order to override the sub-brand configured to the AppID, value can &amp;lt;br/&amp;gt;&lt;br /&gt;
be passed here (e.g. multiple sub-brands in App)&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen&lt;br /&gt;
||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of ad	|| &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt;||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom &amp;lt;br&amp;gt;(no [[Special Characters]])	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let adMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;123456&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * adMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Nielsen API Documentation ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; to pass the channel descriptor information through channelName parameter when the user taps the '''Play''' button on the player. Pass in channelName metadata as described above.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenApi play:([NSDictionary *channel loadChannelInfo)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.play(channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
Call to inform SDK about asset being played. Pass in metadata as described here [[#Configure Payload]], [[#Content Metadata]]&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
Call to inform Nielsen SDK about position in video asset (for VOD pass second within video, for livestreams UTC timestamp in seconds).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi playheadPosition:secondsAsInt];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.playheadPosition(secondsAsInt)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
Call to indicate interruption during playback, e.g. pause. (more on interruption scenarios here: [[#Interruptions during playback]] )&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
Call when content finished playback and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
[[File:appsdkTimeline-DCR.png|icon|link=]]&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
nielsenApi = NielsenInit.createNielsenApi(delegate: self);&lt;br /&gt;
data = loadStaticMetadata();&lt;br /&gt;
nielsenApi.loadMetadata(self.data);&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName)&amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – SDK instance exits from Processing state when this API is called.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== API Call Sequence ==&lt;br /&gt;
=== Use Case 1: Content has no Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use Case 2: Content has Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad=123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after the content is paused (ad starts)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Always call stop irrespective of postroll is followed or not&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Pre-Certification Checklists ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are three primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Limit Ad Tracking'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#Legacy_Opt-out|Legacy Opt-out]]''' - Direct call to SDK; used only for older versions of Nielsen iOS SDK (&amp;lt; 5.1.1.18)&lt;br /&gt;
# '''[[#App_Level_Opt_Out|App Level Opt-Out]]''' - Where [https://developer.apple.com/documentation/adsupport Ad Framework] cannot be leveraged&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS '''SDK Versions 5.1.1.18 and above'''.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's ''Limit Ad Tracking'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Limit Ad Tracking&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
=== Legacy Opt-out ===&lt;br /&gt;
The ''Legacy opt-out'' method is only necessary for Nielsen iOS '''SDK versions less than 5.1.1.18'''.&lt;br /&gt;
&lt;br /&gt;
Nielsen iOS SDK 5.1.1.17 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.&lt;br /&gt;
&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the legacy Nielsen opt-out URL via [[optOutURL]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=swift&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt-out example code ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-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&lt;br /&gt;
&lt;br /&gt;
=== First Party ID (FPID)===&lt;br /&gt;
- The broadcaster must enableFPID in the initialization settings which is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; depending on user consent. This is to be set by the broadcaster when initializing our SDK.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The &amp;lt;code&amp;gt;enableFpid&amp;lt;/code&amp;gt; flag is needed to enable/disable FPID usage for the AppID. The default value for this flag is true. If this flag is changed from true to false, then the AppSDK should wipe out the stored FPID and use a blank value for the FPID parameter in all the pings.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Generated FPID value is stored in the persistent memory until the application is uninstalled from a device or until FPID is wiped out or until it is expired.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The default value for this parameter is 180 days. Once this timeout is reached, the FPID should be regenerated.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Example: disable FPID during init call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;, // sfcode for Poland&lt;br /&gt;
            &amp;quot;enableFpid&amp;quot;: &amp;quot;false&amp;quot; //false = FPID is disabled, true= FPID is enabled&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot; // only for debug builds and see the Nielsen logs&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required Privacy Links ===&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
'''&amp;quot;Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://priv-policy.imrworldwide.com/priv/mobile/pl/pl/optout.html for more information&amp;quot;'''&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
    &lt;br /&gt;
    //Setting background image&lt;br /&gt;
    UIImage *backgroundImage = [UIImage imageNamed:@&amp;quot;new_ios_bg.png&amp;quot;];&lt;br /&gt;
    UIImageView *backgroundImageView=[[UIImageView alloc]initWithFrame:self.view.frame];&lt;br /&gt;
    backgroundImageView.image=backgroundImage;&lt;br /&gt;
    [self.view insertSubview:backgroundImageView atIndex:0];&lt;br /&gt;
&lt;br /&gt;
    self.nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&lt;br /&gt;
    //Initialising the webview&lt;br /&gt;
    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];&lt;br /&gt;
    _wkwebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];&lt;br /&gt;
    _wkwebView.navigationDelegate = self;&lt;br /&gt;
&lt;br /&gt;
     //Getting the optPut URL from SDK&lt;br /&gt;
    NSURL *nsurl=[NSURL URLWithString:[self.nielsenApi optOutURL]];&lt;br /&gt;
&lt;br /&gt;
    //Setting url request in webview&lt;br /&gt;
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];&lt;br /&gt;
&lt;br /&gt;
     //Setting url request in webview&lt;br /&gt;
    [_wkwebView loadRequest:nsrequest];&lt;br /&gt;
&lt;br /&gt;
      //Adding webview to the controller view &lt;br /&gt;
    [self.view addSubview:_wkwebView];   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) {&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== App Level Opt Out ===&lt;br /&gt;
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:&lt;br /&gt;
* Implement the UIWebView delegate method to open the Nielsen Privacy web page&lt;br /&gt;
* Capture user's selection&lt;br /&gt;
* Pass the selection back to the SDK via the &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Capture and forward user selection ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType&lt;br /&gt;
{&lt;br /&gt;
    NSString *command = [NSString stringWithFormat:@&amp;quot;%@&amp;quot;,request.URL];&lt;br /&gt;
    if ([command isEqualToString:kNielsenWebClose]) {&lt;br /&gt;
        // Close the WebView&lt;br /&gt;
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];&lt;br /&gt;
        return NO;&lt;br /&gt;
    }&lt;br /&gt;
    // Retrieve next URL if it’s not opt-in/out selection&lt;br /&gt;
    return (![nAppApiObject userOptOut:command]);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -&amp;gt; Bool {&lt;br /&gt;
&lt;br /&gt;
        let command = request.url?.absoluteString&lt;br /&gt;
        if  command ==  &amp;quot;kNielsenWebClose&amp;quot;{&lt;br /&gt;
&lt;br /&gt;
            self.perform(#selector(closeOptOutView), with: nil, afterDelay: 0)&lt;br /&gt;
&lt;br /&gt;
            return false&lt;br /&gt;
        }    &lt;br /&gt;
        return NielsenAppApi.optOutURL&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== AirPlay ==&lt;br /&gt;
To implement OTT measurement, report OTT changes to the SDK using public API interface: [[updateOTT]]&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;AVAudioSessionPortDescription&amp;lt;/code&amp;gt; has the following values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-airplay &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-screen&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For iOS 11+ some parameters like name and UID have different values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = AirPlay; UID = 0eb63aae-5915-45f1-b0f7-0102a0e50d53 &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = 4335E8A9-1C0A-4251-9000-28CA5FA2F3CF-192731714653291-screen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following code snipped is suggested for AirPlay / mirroring detection on iOS devices.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
– (void)updateOTT:(id)ottInfo;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)handleRouteChanged:(NSNotification *)notification&lt;br /&gt;
{&lt;br /&gt;
NSMutableDictionary *ottDict = [NSMutableDictionary dictionaryWithDictionary: @{@&amp;quot;ottStatus&amp;quot;: @&amp;quot;0&amp;quot;}];&lt;br /&gt;
&lt;br /&gt;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];&lt;br /&gt;
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;&lt;br /&gt;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs) {&lt;br /&gt;
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]) {&lt;br /&gt;
ottDict[@&amp;quot;ottStatus&amp;quot;] = @&amp;quot;1&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceID&amp;quot;] = outputPort.UID;&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.portName isEqualToString:@&amp;quot;AirPlay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if ([outputPort.portName containsString:@&amp;quot;Apple TV&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;appleTV&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.UID hasSuffix:@&amp;quot;airplay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else if ([outputPort.UID hasSuffix:@&amp;quot;screen&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;mirroring&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
[self reportOTTWithDict:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)reportOTTWithDict:(NSDictionary *)ottDict&lt;br /&gt;
{&lt;br /&gt;
[self.nielsenSDK updateOTT:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification === &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChanged(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func handleRouteChanged(_ notification: Notification) {&lt;br /&gt;
var currentStatus: [String: String] = [&amp;quot;ottStatus&amp;quot;: &amp;quot;0&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
let session = AVAudioSession.sharedInstance()&lt;br /&gt;
let currentRoute = session.currentRoute&lt;br /&gt;
for outputPort in currentRoute.outputs {&lt;br /&gt;
if outputPort.portType == AVAudioSessionPortAirPlay {&lt;br /&gt;
currentStatus[&amp;quot;ottStatus&amp;quot;] = &amp;quot;1&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceID&amp;quot;] = outputPort.uid&lt;br /&gt;
&lt;br /&gt;
if outputPort.portName == &amp;quot;AirPlay&amp;quot; {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if outputPort.portName.contains(&amp;quot;Apple TV&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;appleTV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if outputPort.uid.hasSuffix(&amp;quot;airplay&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else if outputPort.uid.hasSuffix(&amp;quot;screen&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;mirroring&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
self.reportOTTUpdate(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK===&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func reportOTTUpdate(_ ottDict: [String: String]) {&lt;br /&gt;
if let nielsenSdk = self.nielsenAppApi {&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories:&lt;br /&gt;
* '''Basic''' - To show the functionality of the Nielsen Simplified API using a standard no-frills player.&lt;br /&gt;
** [[Swift Basic Sample|Swift 4.0 Sample]]&lt;br /&gt;
** [[Objective-c Basic example|Objective-C Sample]]&lt;br /&gt;
** [[Android Basic example|Android Studio Example]]&lt;br /&gt;
&lt;br /&gt;
* '''Advanced''' - Nielsen Simplified API integrated into a custom video player.&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Swift 4.0 Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Objective-C Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Java/Android Studio Sample]&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_iOS_SDK&amp;diff=6535</id>
		<title>DCR Italy Static iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_iOS_SDK&amp;diff=6535"/>
		<updated>2023-09-28T11:14:45Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a sub section / page in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
This Guide is for the Implementation of Static Measurement. For implementation of Video, please refer to the [[DCR Italy Video iOS SDK |iOS DCR Video Implementation Guide.]]&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode to enable '''Static Measurement''' within you APP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Static_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ DCR_and_DTVR_with_iOS17_or_TVOS17|Nielsen Digital Measurement and iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
Italian Clients:&lt;br /&gt;
*&amp;quot;it&amp;quot;&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;it&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;LandingVC.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class LandingVC: UIViewController, NielsenAppApiDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var nielsenMain : NielsenAppApi!&lt;br /&gt;
    var sdkMethods : SDKMethods!&lt;br /&gt;
    var data : [String : Any]!&lt;br /&gt;
&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
    override func viewDidAppear(_ animated: Bool) {      &lt;br /&gt;
        self.data = sdkMethods.loadStaticMaster()     // This is just an example of populating the metadata&lt;br /&gt;
        self.nielsenMain.loadMetadata(self.data)&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Populate and Pass Metadata Object ==&lt;br /&gt;
The Nielsen SDK is able to monitor Application launch events and how long your app has been running.  Once the Nielsen SDK has been Initialized, pass &amp;lt;code&amp;gt;&amp;quot;type&amp;quot;:'static'&amp;lt;/code&amp;gt; as a JSON object via loadMetadata.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        let staticMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;static&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;HomePage&amp;quot;,&lt;br /&gt;
            &amp;quot;section&amp;quot;: &amp;quot;Home_EntityName_iOS&amp;quot;&lt;br /&gt;
        ];&lt;br /&gt;
         self.nielsenAppApi?.loadMetadata(staticMetadata)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
   NSDictionary *staticMetadata = @&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;static&amp;quot;,&lt;br /&gt;
        &amp;quot;assetid&amp;quot;: &amp;quot;HomePage&amp;quot;,&lt;br /&gt;
        &amp;quot;section&amp;quot;: &amp;quot;Home_EntityName_iOS&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
[nielsenApi loadMetadata:(staticMetadata)];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
The above code would be inserted only for the &amp;quot;home section&amp;quot; within your app.&lt;br /&gt;
&lt;br /&gt;
=== Nielsen SDK Metadata ===&lt;br /&gt;
The following table defines the staticMetadata reserved keys:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !! Data Type !! Value !! Required?&lt;br /&gt;
|-&lt;br /&gt;
| type || asset type || fixed || &amp;lt;code&amp;gt;'static'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || Unique ID for each article. For the Italian Market only the home page/ landing page must be tagged || dynamic || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| section || section of the App to be measured &amp;lt;/br&amp;gt; EntityName = brand name or sub-brand name|| dynamic || &amp;lt;code&amp;gt;Home_EntityName_iOS&amp;lt;/code&amp;gt; for iOS App  || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Static_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Static_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the optOutStatus property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
#* '''Example Production Initialization Call''' - Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
=== iOS Example: ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit: NSObject {&lt;br /&gt;
    class func createNielsenAppApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
    let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;&lt;br /&gt;
            // Remove Flag:   &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]&lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Video_iOS_SDK&amp;diff=6534</id>
		<title>DCR Italy Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Video_iOS_SDK&amp;diff=6534"/>
		<updated>2023-09-28T11:14:07Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ DCR_and_DTVR_with_iOS17_or_TVOS17|Nielsen Digital Measurement and iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
Italian Clients:&lt;br /&gt;
*&amp;quot;it&amp;quot;&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;it&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Content Metadata ===&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || &amp;lt;code&amp;gt;seconds&amp;lt;/code&amp;gt; (0 for live stream) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || the airdate in the linear TV || YYYYMMDD HH24:MI:SS || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
VOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current video asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the videoplayer is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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 &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note:&lt;br /&gt;
*For Audiweb there is no need to tag ads in video stream ... please see 1st example about how to use the SDK without ads.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing videos or watching a new video, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6533</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6533"/>
		<updated>2023-09-28T11:13:28Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ DCR_and_DTVR_with_iOS17_or_TVOS17|Nielsen Digital Measurement and iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  let adMetadata = [&lt;br /&gt;
        &amp;quot;assetid&amp;quot; : &amp;quot;unique_postroll_ad_id&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; : &amp;quot;preroll&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6522</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6522"/>
		<updated>2023-09-13T14:39:01Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  let adMetadata = [&lt;br /&gt;
        &amp;quot;assetid&amp;quot; : &amp;quot;unique_postroll_ad_id&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; : &amp;quot;preroll&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_iOS_SDK&amp;diff=6521</id>
		<title>DCR Italy Static iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_iOS_SDK&amp;diff=6521"/>
		<updated>2023-09-13T14:38:08Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a sub section / page in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
This Guide is for the Implementation of Static Measurement. For implementation of Video, please refer to the [[DCR Italy Video iOS SDK |iOS DCR Video Implementation Guide.]]&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode to enable '''Static Measurement''' within you APP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Static_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
Italian Clients:&lt;br /&gt;
*&amp;quot;it&amp;quot;&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;it&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;LandingVC.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class LandingVC: UIViewController, NielsenAppApiDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var nielsenMain : NielsenAppApi!&lt;br /&gt;
    var sdkMethods : SDKMethods!&lt;br /&gt;
    var data : [String : Any]!&lt;br /&gt;
&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
    override func viewDidAppear(_ animated: Bool) {      &lt;br /&gt;
        self.data = sdkMethods.loadStaticMaster()     // This is just an example of populating the metadata&lt;br /&gt;
        self.nielsenMain.loadMetadata(self.data)&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Populate and Pass Metadata Object ==&lt;br /&gt;
The Nielsen SDK is able to monitor Application launch events and how long your app has been running.  Once the Nielsen SDK has been Initialized, pass &amp;lt;code&amp;gt;&amp;quot;type&amp;quot;:'static'&amp;lt;/code&amp;gt; as a JSON object via loadMetadata.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        let staticMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;static&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;HomePage&amp;quot;,&lt;br /&gt;
            &amp;quot;section&amp;quot;: &amp;quot;Home_EntityName_iOS&amp;quot;&lt;br /&gt;
        ];&lt;br /&gt;
         self.nielsenAppApi?.loadMetadata(staticMetadata)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
   NSDictionary *staticMetadata = @&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;static&amp;quot;,&lt;br /&gt;
        &amp;quot;assetid&amp;quot;: &amp;quot;HomePage&amp;quot;,&lt;br /&gt;
        &amp;quot;section&amp;quot;: &amp;quot;Home_EntityName_iOS&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
[nielsenApi loadMetadata:(staticMetadata)];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
The above code would be inserted only for the &amp;quot;home section&amp;quot; within your app.&lt;br /&gt;
&lt;br /&gt;
=== Nielsen SDK Metadata ===&lt;br /&gt;
The following table defines the staticMetadata reserved keys:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !! Data Type !! Value !! Required?&lt;br /&gt;
|-&lt;br /&gt;
| type || asset type || fixed || &amp;lt;code&amp;gt;'static'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || Unique ID for each article. For the Italian Market only the home page/ landing page must be tagged || dynamic || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| section || section of the App to be measured &amp;lt;/br&amp;gt; EntityName = brand name or sub-brand name|| dynamic || &amp;lt;code&amp;gt;Home_EntityName_iOS&amp;lt;/code&amp;gt; for iOS App  || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Static_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Static_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the optOutStatus property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
#* '''Example Production Initialization Call''' - Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
=== iOS Example: ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit: NSObject {&lt;br /&gt;
    class func createNielsenAppApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
    let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;&lt;br /&gt;
            // Remove Flag:   &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]&lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Video_iOS_SDK&amp;diff=6520</id>
		<title>DCR Italy Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Video_iOS_SDK&amp;diff=6520"/>
		<updated>2023-09-13T14:37:27Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
Italian Clients:&lt;br /&gt;
*&amp;quot;it&amp;quot;&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;it&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Content Metadata ===&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || &amp;lt;code&amp;gt;seconds&amp;lt;/code&amp;gt; (0 for live stream) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || the airdate in the linear TV || YYYYMMDD HH24:MI:SS || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
VOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current video asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the videoplayer is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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 &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note:&lt;br /&gt;
*For Audiweb there is no need to tag ads in video stream ... please see 1st example about how to use the SDK without ads.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing videos or watching a new video, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6519</id>
		<title>DCR Poland Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6519"/>
		<updated>2023-09-13T12:56:34Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 30px;&amp;quot; |&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''sfcode''' || Environment that the SDK must point to || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
Do not declare the Nielsen '''imrworldwide.com''' domain in the privacy manifest.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
&lt;br /&gt;
* The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Optional; automatically detected in SDK 6.0.0.4 and above || Nielsen Sample App&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
* &amp;quot;pl&amp;quot; &lt;br /&gt;
|| Nielsen-specified || Yes || pl&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;INFO&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': DO NOT activate the Debug flag in a production environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift  = &lt;br /&gt;
Swift 4.0 Example:&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample code using AVPlayer.&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NielsenInit.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NielsenInit&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate&lt;br /&gt;
{    &lt;br /&gt;
    NSDictionary *appInformation = @{ @&amp;quot;appid&amp;quot;: @&amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                            @&amp;quot;appversion&amp;quot;: @&amp;quot;1.0&amp;quot;,&lt;br /&gt;
                            @&amp;quot;sfcode&amp;quot;: @&amp;quot;pl&amp;quot;,&lt;br /&gt;
                            @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;, };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NielsenInit.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NielsenInit : NSObject&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sample Code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Payload ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** 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.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
    &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;C77664&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Program S2, E3&amp;quot;,&lt;br /&gt;
    &amp;quot;isfullepisode&amp;quot;: &amp;quot;Yes&amp;quot;,&lt;br /&gt;
    &amp;quot;program&amp;quot;: &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
    &amp;quot;airdate&amp;quot;: &amp;quot;20171020 10:05:00&amp;quot;,&lt;br /&gt;
    &amp;quot;adloadtype&amp;quot;: &amp;quot;2&amp;quot;,&lt;br /&gt;
    &amp;quot;segB&amp;quot;: &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
    &amp;quot;segC&amp;quot;: &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * channelInfo = @ {&lt;br /&gt;
    @ &amp;quot;channelName&amp;quot;: @ &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
        @ &amp;quot;assetid&amp;quot;: @ &amp;quot;C77664&amp;quot;,&lt;br /&gt;
        @ &amp;quot;title&amp;quot;: @ &amp;quot;S2,E3&amp;quot;,&lt;br /&gt;
        @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
        @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
        @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
        @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20180120 10:00:00&amp;quot;,&lt;br /&gt;
        @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;,&lt;br /&gt;
        @ &amp;quot;segB&amp;quot;: @ &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
        @ &amp;quot;segC&amp;quot;: @ &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== ChannelName metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode / clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type || type of asset	|| &amp;quot;content&amp;quot; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| unique ID assigned to asset (max 64 characters; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) || custom (no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| (string) name of program (max 254 characters)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| (string) episode title (max 254 characters)	|| custom - no backslash allowed in string (because of 3rd party data processing) || ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| (int) length of content in seconds	|| 86400 seconds for live stream. For Event-Livestreams planned length. For VoD video length||	✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear TV. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;	||	YYYY-MM-DDTHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS+xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS-xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDD HH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
MM-DD-YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
MM/DD/YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
 (pass beginning of epoch if unknown)&lt;br /&gt;
	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag	||	&amp;quot;y&amp;quot;- full episode, &amp;quot;n&amp;quot;- non full episode	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads ||  ✓&lt;br /&gt;
|-&lt;br /&gt;
| progen || program genre	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| crossId1 || standard episode ID	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| clientid	|| &lt;br /&gt;
parent ID – value is automatically populated through provided AppID.&amp;lt;br/&amp;gt;&lt;br /&gt;
In order to override the brand configured to the AppID, pass parent &amp;lt;br/&amp;gt;&lt;br /&gt;
value here and the sub-brand ID associated to that brand in the subbrand &amp;lt;br/&amp;gt;&lt;br /&gt;
key (e.g. multiple brands in App)	&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen	&lt;br /&gt;
||&lt;br /&gt;
|-&lt;br /&gt;
| subbrand	|| vcid/sub-brand ID – value is automatically populated through provided&amp;lt;br/&amp;gt;&lt;br /&gt;
AppID. In order to override the sub-brand configured to the AppID, value can &amp;lt;br/&amp;gt;&lt;br /&gt;
be passed here (e.g. multiple sub-brands in App)&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen&lt;br /&gt;
||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of ad	|| &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt;||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom &amp;lt;br&amp;gt;(no [[Special Characters]])	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let adMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;123456&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * adMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Nielsen API Documentation ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; to pass the channel descriptor information through channelName parameter when the user taps the '''Play''' button on the player. Pass in channelName metadata as described above.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenApi play:([NSDictionary *channel loadChannelInfo)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.play(channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
Call to inform SDK about asset being played. Pass in metadata as described here [[#Configure Payload]], [[#Content Metadata]]&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
Call to inform Nielsen SDK about position in video asset (for VOD pass second within video, for livestreams UTC timestamp in seconds).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi playheadPosition:secondsAsInt];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.playheadPosition(secondsAsInt)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
Call to indicate interruption during playback, e.g. pause. (more on interruption scenarios here: [[#Interruptions during playback]] )&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
Call when content finished playback and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
[[File:appsdkTimeline-DCR.png|icon|link=]]&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
nielsenApi = NielsenInit.createNielsenApi(delegate: self);&lt;br /&gt;
data = loadStaticMetadata();&lt;br /&gt;
nielsenApi.loadMetadata(self.data);&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName)&amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – SDK instance exits from Processing state when this API is called.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== API Call Sequence ==&lt;br /&gt;
=== Use Case 1: Content has no Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use Case 2: Content has Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad=123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after the content is paused (ad starts)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Always call stop irrespective of postroll is followed or not&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Pre-Certification Checklists ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are three primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Limit Ad Tracking'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#Legacy_Opt-out|Legacy Opt-out]]''' - Direct call to SDK; used only for older versions of Nielsen iOS SDK (&amp;lt; 5.1.1.18)&lt;br /&gt;
# '''[[#App_Level_Opt_Out|App Level Opt-Out]]''' - Where [https://developer.apple.com/documentation/adsupport Ad Framework] cannot be leveraged&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS '''SDK Versions 5.1.1.18 and above'''.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's ''Limit Ad Tracking'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Limit Ad Tracking&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
=== Legacy Opt-out ===&lt;br /&gt;
The ''Legacy opt-out'' method is only necessary for Nielsen iOS '''SDK versions less than 5.1.1.18'''.&lt;br /&gt;
&lt;br /&gt;
Nielsen iOS SDK 5.1.1.17 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.&lt;br /&gt;
&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the legacy Nielsen opt-out URL via [[optOutURL]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=swift&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt-out example code ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-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&lt;br /&gt;
&lt;br /&gt;
=== First Party ID (FPID)===&lt;br /&gt;
- The broadcaster must enableFPID in the initialization settings which is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; depending on user consent. This is to be set by the broadcaster when initializing our SDK.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The &amp;lt;code&amp;gt;enableFpid&amp;lt;/code&amp;gt; flag is needed to enable/disable FPID usage for the AppID. The default value for this flag is true. If this flag is changed from true to false, then the AppSDK should wipe out the stored FPID and use a blank value for the FPID parameter in all the pings.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Generated FPID value is stored in the persistent memory until the application is uninstalled from a device or until FPID is wiped out or until it is expired.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The default value for this parameter is 180 days. Once this timeout is reached, the FPID should be regenerated.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Example: disable FPID during init call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;, // sfcode for Poland&lt;br /&gt;
            &amp;quot;enableFpid&amp;quot;: &amp;quot;false&amp;quot; //false = FPID is disabled, true= FPID is enabled&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot; // only for debug builds and see the Nielsen logs&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required Privacy Links ===&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
'''&amp;quot;Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://priv-policy.imrworldwide.com/priv/mobile/pl/pl/optout.html for more information&amp;quot;'''&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
    &lt;br /&gt;
    //Setting background image&lt;br /&gt;
    UIImage *backgroundImage = [UIImage imageNamed:@&amp;quot;new_ios_bg.png&amp;quot;];&lt;br /&gt;
    UIImageView *backgroundImageView=[[UIImageView alloc]initWithFrame:self.view.frame];&lt;br /&gt;
    backgroundImageView.image=backgroundImage;&lt;br /&gt;
    [self.view insertSubview:backgroundImageView atIndex:0];&lt;br /&gt;
&lt;br /&gt;
    self.nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&lt;br /&gt;
    //Initialising the webview&lt;br /&gt;
    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];&lt;br /&gt;
    _wkwebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];&lt;br /&gt;
    _wkwebView.navigationDelegate = self;&lt;br /&gt;
&lt;br /&gt;
     //Getting the optPut URL from SDK&lt;br /&gt;
    NSURL *nsurl=[NSURL URLWithString:[self.nielsenApi optOutURL]];&lt;br /&gt;
&lt;br /&gt;
    //Setting url request in webview&lt;br /&gt;
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];&lt;br /&gt;
&lt;br /&gt;
     //Setting url request in webview&lt;br /&gt;
    [_wkwebView loadRequest:nsrequest];&lt;br /&gt;
&lt;br /&gt;
      //Adding webview to the controller view &lt;br /&gt;
    [self.view addSubview:_wkwebView];   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) {&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== App Level Opt Out ===&lt;br /&gt;
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:&lt;br /&gt;
* Implement the UIWebView delegate method to open the Nielsen Privacy web page&lt;br /&gt;
* Capture user's selection&lt;br /&gt;
* Pass the selection back to the SDK via the &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Capture and forward user selection ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType&lt;br /&gt;
{&lt;br /&gt;
    NSString *command = [NSString stringWithFormat:@&amp;quot;%@&amp;quot;,request.URL];&lt;br /&gt;
    if ([command isEqualToString:kNielsenWebClose]) {&lt;br /&gt;
        // Close the WebView&lt;br /&gt;
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];&lt;br /&gt;
        return NO;&lt;br /&gt;
    }&lt;br /&gt;
    // Retrieve next URL if it’s not opt-in/out selection&lt;br /&gt;
    return (![nAppApiObject userOptOut:command]);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -&amp;gt; Bool {&lt;br /&gt;
&lt;br /&gt;
        let command = request.url?.absoluteString&lt;br /&gt;
        if  command ==  &amp;quot;kNielsenWebClose&amp;quot;{&lt;br /&gt;
&lt;br /&gt;
            self.perform(#selector(closeOptOutView), with: nil, afterDelay: 0)&lt;br /&gt;
&lt;br /&gt;
            return false&lt;br /&gt;
        }    &lt;br /&gt;
        return NielsenAppApi.optOutURL&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== AirPlay ==&lt;br /&gt;
To implement OTT measurement, report OTT changes to the SDK using public API interface: [[updateOTT]]&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;AVAudioSessionPortDescription&amp;lt;/code&amp;gt; has the following values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-airplay &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-screen&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For iOS 11+ some parameters like name and UID have different values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = AirPlay; UID = 0eb63aae-5915-45f1-b0f7-0102a0e50d53 &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = 4335E8A9-1C0A-4251-9000-28CA5FA2F3CF-192731714653291-screen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following code snipped is suggested for AirPlay / mirroring detection on iOS devices.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
– (void)updateOTT:(id)ottInfo;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)handleRouteChanged:(NSNotification *)notification&lt;br /&gt;
{&lt;br /&gt;
NSMutableDictionary *ottDict = [NSMutableDictionary dictionaryWithDictionary: @{@&amp;quot;ottStatus&amp;quot;: @&amp;quot;0&amp;quot;}];&lt;br /&gt;
&lt;br /&gt;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];&lt;br /&gt;
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;&lt;br /&gt;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs) {&lt;br /&gt;
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]) {&lt;br /&gt;
ottDict[@&amp;quot;ottStatus&amp;quot;] = @&amp;quot;1&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceID&amp;quot;] = outputPort.UID;&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.portName isEqualToString:@&amp;quot;AirPlay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if ([outputPort.portName containsString:@&amp;quot;Apple TV&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;appleTV&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.UID hasSuffix:@&amp;quot;airplay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else if ([outputPort.UID hasSuffix:@&amp;quot;screen&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;mirroring&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
[self reportOTTWithDict:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)reportOTTWithDict:(NSDictionary *)ottDict&lt;br /&gt;
{&lt;br /&gt;
[self.nielsenSDK updateOTT:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification === &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChanged(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func handleRouteChanged(_ notification: Notification) {&lt;br /&gt;
var currentStatus: [String: String] = [&amp;quot;ottStatus&amp;quot;: &amp;quot;0&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
let session = AVAudioSession.sharedInstance()&lt;br /&gt;
let currentRoute = session.currentRoute&lt;br /&gt;
for outputPort in currentRoute.outputs {&lt;br /&gt;
if outputPort.portType == AVAudioSessionPortAirPlay {&lt;br /&gt;
currentStatus[&amp;quot;ottStatus&amp;quot;] = &amp;quot;1&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceID&amp;quot;] = outputPort.uid&lt;br /&gt;
&lt;br /&gt;
if outputPort.portName == &amp;quot;AirPlay&amp;quot; {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if outputPort.portName.contains(&amp;quot;Apple TV&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;appleTV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if outputPort.uid.hasSuffix(&amp;quot;airplay&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else if outputPort.uid.hasSuffix(&amp;quot;screen&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;mirroring&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
self.reportOTTUpdate(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK===&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func reportOTTUpdate(_ ottDict: [String: String]) {&lt;br /&gt;
if let nielsenSdk = self.nielsenAppApi {&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories:&lt;br /&gt;
* '''Basic''' - To show the functionality of the Nielsen Simplified API using a standard no-frills player.&lt;br /&gt;
** [[Swift Basic Sample|Swift 4.0 Sample]]&lt;br /&gt;
** [[Objective-c Basic example|Objective-C Sample]]&lt;br /&gt;
** [[Android Basic example|Android Studio Example]]&lt;br /&gt;
&lt;br /&gt;
* '''Advanced''' - Nielsen Simplified API integrated into a custom video player.&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Swift 4.0 Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Objective-C Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Java/Android Studio Sample]&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Video_iOS_SDK&amp;diff=6518</id>
		<title>DCR Italy Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Video_iOS_SDK&amp;diff=6518"/>
		<updated>2023-09-13T12:54:28Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
Italian Clients:&lt;br /&gt;
*&amp;quot;it&amp;quot;&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;it&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Content Metadata ===&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || &amp;lt;code&amp;gt;seconds&amp;lt;/code&amp;gt; (0 for live stream) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || the airdate in the linear TV || YYYYMMDD HH24:MI:SS || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
VOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current video asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the videoplayer is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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 &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note:&lt;br /&gt;
*For Audiweb there is no need to tag ads in video stream ... please see 1st example about how to use the SDK without ads.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing videos or watching a new video, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_iOS_SDK&amp;diff=6517</id>
		<title>DCR Italy Static iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_iOS_SDK&amp;diff=6517"/>
		<updated>2023-09-13T12:53:34Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a sub section / page in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
This Guide is for the Implementation of Static Measurement. For implementation of Video, please refer to the [[DCR Italy Video iOS SDK |iOS DCR Video Implementation Guide.]]&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode to enable '''Static Measurement''' within you APP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Static_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
Italian Clients:&lt;br /&gt;
*&amp;quot;it&amp;quot;&lt;br /&gt;
|| Nielsen-specified || Yes || &amp;quot;it&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;LandingVC.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class LandingVC: UIViewController, NielsenAppApiDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var nielsenMain : NielsenAppApi!&lt;br /&gt;
    var sdkMethods : SDKMethods!&lt;br /&gt;
    var data : [String : Any]!&lt;br /&gt;
&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
    override func viewDidAppear(_ animated: Bool) {      &lt;br /&gt;
        self.data = sdkMethods.loadStaticMaster()     // This is just an example of populating the metadata&lt;br /&gt;
        self.nielsenMain.loadMetadata(self.data)&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Populate and Pass Metadata Object ==&lt;br /&gt;
The Nielsen SDK is able to monitor Application launch events and how long your app has been running.  Once the Nielsen SDK has been Initialized, pass &amp;lt;code&amp;gt;&amp;quot;type&amp;quot;:'static'&amp;lt;/code&amp;gt; as a JSON object via loadMetadata.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        let staticMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;static&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;HomePage&amp;quot;,&lt;br /&gt;
            &amp;quot;section&amp;quot;: &amp;quot;Home_EntityName_iOS&amp;quot;&lt;br /&gt;
        ];&lt;br /&gt;
         self.nielsenAppApi?.loadMetadata(staticMetadata)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
   NSDictionary *staticMetadata = @&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;static&amp;quot;,&lt;br /&gt;
        &amp;quot;assetid&amp;quot;: &amp;quot;HomePage&amp;quot;,&lt;br /&gt;
        &amp;quot;section&amp;quot;: &amp;quot;Home_EntityName_iOS&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
[nielsenApi loadMetadata:(staticMetadata)];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
The above code would be inserted only for the &amp;quot;home section&amp;quot; within your app.&lt;br /&gt;
&lt;br /&gt;
=== Nielsen SDK Metadata ===&lt;br /&gt;
The following table defines the staticMetadata reserved keys:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !! Data Type !! Value !! Required?&lt;br /&gt;
|-&lt;br /&gt;
| type || asset type || fixed || &amp;lt;code&amp;gt;'static'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || Unique ID for each article. For the Italian Market only the home page/ landing page must be tagged || dynamic || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| section || section of the App to be measured &amp;lt;/br&amp;gt; EntityName = brand name or sub-brand name|| dynamic || &amp;lt;code&amp;gt;Home_EntityName_iOS&amp;lt;/code&amp;gt; for iOS App  || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Static_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Static_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the optOutStatus property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
#* '''Example Production Initialization Call''' - Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
=== iOS Example: ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit: NSObject {&lt;br /&gt;
    class func createNielsenAppApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
    let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;it&amp;quot;&lt;br /&gt;
            // Remove Flag:   &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]&lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6516</id>
		<title>DCR Poland Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6516"/>
		<updated>2023-09-13T12:52:30Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 30px;&amp;quot; |&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''sfcode''' || Environment that the SDK must point to || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
*  [[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
&lt;br /&gt;
* The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Optional; automatically detected in SDK 6.0.0.4 and above || Nielsen Sample App&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
* &amp;quot;pl&amp;quot; &lt;br /&gt;
|| Nielsen-specified || Yes || pl&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;INFO&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': DO NOT activate the Debug flag in a production environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift  = &lt;br /&gt;
Swift 4.0 Example:&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample code using AVPlayer.&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NielsenInit.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NielsenInit&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate&lt;br /&gt;
{    &lt;br /&gt;
    NSDictionary *appInformation = @{ @&amp;quot;appid&amp;quot;: @&amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                            @&amp;quot;appversion&amp;quot;: @&amp;quot;1.0&amp;quot;,&lt;br /&gt;
                            @&amp;quot;sfcode&amp;quot;: @&amp;quot;pl&amp;quot;,&lt;br /&gt;
                            @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;, };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NielsenInit.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NielsenInit : NSObject&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sample Code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Payload ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** 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.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
    &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;C77664&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Program S2, E3&amp;quot;,&lt;br /&gt;
    &amp;quot;isfullepisode&amp;quot;: &amp;quot;Yes&amp;quot;,&lt;br /&gt;
    &amp;quot;program&amp;quot;: &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
    &amp;quot;airdate&amp;quot;: &amp;quot;20171020 10:05:00&amp;quot;,&lt;br /&gt;
    &amp;quot;adloadtype&amp;quot;: &amp;quot;2&amp;quot;,&lt;br /&gt;
    &amp;quot;segB&amp;quot;: &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
    &amp;quot;segC&amp;quot;: &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * channelInfo = @ {&lt;br /&gt;
    @ &amp;quot;channelName&amp;quot;: @ &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
        @ &amp;quot;assetid&amp;quot;: @ &amp;quot;C77664&amp;quot;,&lt;br /&gt;
        @ &amp;quot;title&amp;quot;: @ &amp;quot;S2,E3&amp;quot;,&lt;br /&gt;
        @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
        @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
        @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
        @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20180120 10:00:00&amp;quot;,&lt;br /&gt;
        @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;,&lt;br /&gt;
        @ &amp;quot;segB&amp;quot;: @ &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
        @ &amp;quot;segC&amp;quot;: @ &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== ChannelName metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode / clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type || type of asset	|| &amp;quot;content&amp;quot; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| unique ID assigned to asset (max 64 characters; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) || custom (no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| (string) name of program (max 254 characters)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| (string) episode title (max 254 characters)	|| custom - no backslash allowed in string (because of 3rd party data processing) || ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| (int) length of content in seconds	|| 86400 seconds for live stream. For Event-Livestreams planned length. For VoD video length||	✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear TV. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;	||	YYYY-MM-DDTHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS+xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS-xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDD HH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
MM-DD-YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
MM/DD/YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
 (pass beginning of epoch if unknown)&lt;br /&gt;
	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag	||	&amp;quot;y&amp;quot;- full episode, &amp;quot;n&amp;quot;- non full episode	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads ||  ✓&lt;br /&gt;
|-&lt;br /&gt;
| progen || program genre	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| crossId1 || standard episode ID	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| clientid	|| &lt;br /&gt;
parent ID – value is automatically populated through provided AppID.&amp;lt;br/&amp;gt;&lt;br /&gt;
In order to override the brand configured to the AppID, pass parent &amp;lt;br/&amp;gt;&lt;br /&gt;
value here and the sub-brand ID associated to that brand in the subbrand &amp;lt;br/&amp;gt;&lt;br /&gt;
key (e.g. multiple brands in App)	&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen	&lt;br /&gt;
||&lt;br /&gt;
|-&lt;br /&gt;
| subbrand	|| vcid/sub-brand ID – value is automatically populated through provided&amp;lt;br/&amp;gt;&lt;br /&gt;
AppID. In order to override the sub-brand configured to the AppID, value can &amp;lt;br/&amp;gt;&lt;br /&gt;
be passed here (e.g. multiple sub-brands in App)&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen&lt;br /&gt;
||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of ad	|| &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt;||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom &amp;lt;br&amp;gt;(no [[Special Characters]])	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let adMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;123456&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * adMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Nielsen API Documentation ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; to pass the channel descriptor information through channelName parameter when the user taps the '''Play''' button on the player. Pass in channelName metadata as described above.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenApi play:([NSDictionary *channel loadChannelInfo)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.play(channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
Call to inform SDK about asset being played. Pass in metadata as described here [[#Configure Payload]], [[#Content Metadata]]&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
Call to inform Nielsen SDK about position in video asset (for VOD pass second within video, for livestreams UTC timestamp in seconds).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi playheadPosition:secondsAsInt];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.playheadPosition(secondsAsInt)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
Call to indicate interruption during playback, e.g. pause. (more on interruption scenarios here: [[#Interruptions during playback]] )&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
Call when content finished playback and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
[[File:appsdkTimeline-DCR.png|icon|link=]]&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
nielsenApi = NielsenInit.createNielsenApi(delegate: self);&lt;br /&gt;
data = loadStaticMetadata();&lt;br /&gt;
nielsenApi.loadMetadata(self.data);&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName)&amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – SDK instance exits from Processing state when this API is called.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== API Call Sequence ==&lt;br /&gt;
=== Use Case 1: Content has no Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use Case 2: Content has Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad=123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after the content is paused (ad starts)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Always call stop irrespective of postroll is followed or not&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Pre-Certification Checklists ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are three primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Limit Ad Tracking'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#Legacy_Opt-out|Legacy Opt-out]]''' - Direct call to SDK; used only for older versions of Nielsen iOS SDK (&amp;lt; 5.1.1.18)&lt;br /&gt;
# '''[[#App_Level_Opt_Out|App Level Opt-Out]]''' - Where [https://developer.apple.com/documentation/adsupport Ad Framework] cannot be leveraged&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS '''SDK Versions 5.1.1.18 and above'''.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's ''Limit Ad Tracking'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Limit Ad Tracking&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
=== Legacy Opt-out ===&lt;br /&gt;
The ''Legacy opt-out'' method is only necessary for Nielsen iOS '''SDK versions less than 5.1.1.18'''.&lt;br /&gt;
&lt;br /&gt;
Nielsen iOS SDK 5.1.1.17 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.&lt;br /&gt;
&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the legacy Nielsen opt-out URL via [[optOutURL]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=swift&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt-out example code ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-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&lt;br /&gt;
&lt;br /&gt;
=== First Party ID (FPID)===&lt;br /&gt;
- The broadcaster must enableFPID in the initialization settings which is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; depending on user consent. This is to be set by the broadcaster when initializing our SDK.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The &amp;lt;code&amp;gt;enableFpid&amp;lt;/code&amp;gt; flag is needed to enable/disable FPID usage for the AppID. The default value for this flag is true. If this flag is changed from true to false, then the AppSDK should wipe out the stored FPID and use a blank value for the FPID parameter in all the pings.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Generated FPID value is stored in the persistent memory until the application is uninstalled from a device or until FPID is wiped out or until it is expired.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The default value for this parameter is 180 days. Once this timeout is reached, the FPID should be regenerated.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Example: disable FPID during init call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;, // sfcode for Poland&lt;br /&gt;
            &amp;quot;enableFpid&amp;quot;: &amp;quot;false&amp;quot; //false = FPID is disabled, true= FPID is enabled&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot; // only for debug builds and see the Nielsen logs&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required Privacy Links ===&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
'''&amp;quot;Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://priv-policy.imrworldwide.com/priv/mobile/pl/pl/optout.html for more information&amp;quot;'''&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
    &lt;br /&gt;
    //Setting background image&lt;br /&gt;
    UIImage *backgroundImage = [UIImage imageNamed:@&amp;quot;new_ios_bg.png&amp;quot;];&lt;br /&gt;
    UIImageView *backgroundImageView=[[UIImageView alloc]initWithFrame:self.view.frame];&lt;br /&gt;
    backgroundImageView.image=backgroundImage;&lt;br /&gt;
    [self.view insertSubview:backgroundImageView atIndex:0];&lt;br /&gt;
&lt;br /&gt;
    self.nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&lt;br /&gt;
    //Initialising the webview&lt;br /&gt;
    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];&lt;br /&gt;
    _wkwebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];&lt;br /&gt;
    _wkwebView.navigationDelegate = self;&lt;br /&gt;
&lt;br /&gt;
     //Getting the optPut URL from SDK&lt;br /&gt;
    NSURL *nsurl=[NSURL URLWithString:[self.nielsenApi optOutURL]];&lt;br /&gt;
&lt;br /&gt;
    //Setting url request in webview&lt;br /&gt;
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];&lt;br /&gt;
&lt;br /&gt;
     //Setting url request in webview&lt;br /&gt;
    [_wkwebView loadRequest:nsrequest];&lt;br /&gt;
&lt;br /&gt;
      //Adding webview to the controller view &lt;br /&gt;
    [self.view addSubview:_wkwebView];   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) {&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== App Level Opt Out ===&lt;br /&gt;
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:&lt;br /&gt;
* Implement the UIWebView delegate method to open the Nielsen Privacy web page&lt;br /&gt;
* Capture user's selection&lt;br /&gt;
* Pass the selection back to the SDK via the &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Capture and forward user selection ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType&lt;br /&gt;
{&lt;br /&gt;
    NSString *command = [NSString stringWithFormat:@&amp;quot;%@&amp;quot;,request.URL];&lt;br /&gt;
    if ([command isEqualToString:kNielsenWebClose]) {&lt;br /&gt;
        // Close the WebView&lt;br /&gt;
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];&lt;br /&gt;
        return NO;&lt;br /&gt;
    }&lt;br /&gt;
    // Retrieve next URL if it’s not opt-in/out selection&lt;br /&gt;
    return (![nAppApiObject userOptOut:command]);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -&amp;gt; Bool {&lt;br /&gt;
&lt;br /&gt;
        let command = request.url?.absoluteString&lt;br /&gt;
        if  command ==  &amp;quot;kNielsenWebClose&amp;quot;{&lt;br /&gt;
&lt;br /&gt;
            self.perform(#selector(closeOptOutView), with: nil, afterDelay: 0)&lt;br /&gt;
&lt;br /&gt;
            return false&lt;br /&gt;
        }    &lt;br /&gt;
        return NielsenAppApi.optOutURL&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== AirPlay ==&lt;br /&gt;
To implement OTT measurement, report OTT changes to the SDK using public API interface: [[updateOTT]]&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;AVAudioSessionPortDescription&amp;lt;/code&amp;gt; has the following values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-airplay &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-screen&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For iOS 11+ some parameters like name and UID have different values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = AirPlay; UID = 0eb63aae-5915-45f1-b0f7-0102a0e50d53 &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = 4335E8A9-1C0A-4251-9000-28CA5FA2F3CF-192731714653291-screen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following code snipped is suggested for AirPlay / mirroring detection on iOS devices.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
– (void)updateOTT:(id)ottInfo;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)handleRouteChanged:(NSNotification *)notification&lt;br /&gt;
{&lt;br /&gt;
NSMutableDictionary *ottDict = [NSMutableDictionary dictionaryWithDictionary: @{@&amp;quot;ottStatus&amp;quot;: @&amp;quot;0&amp;quot;}];&lt;br /&gt;
&lt;br /&gt;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];&lt;br /&gt;
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;&lt;br /&gt;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs) {&lt;br /&gt;
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]) {&lt;br /&gt;
ottDict[@&amp;quot;ottStatus&amp;quot;] = @&amp;quot;1&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceID&amp;quot;] = outputPort.UID;&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.portName isEqualToString:@&amp;quot;AirPlay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if ([outputPort.portName containsString:@&amp;quot;Apple TV&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;appleTV&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.UID hasSuffix:@&amp;quot;airplay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else if ([outputPort.UID hasSuffix:@&amp;quot;screen&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;mirroring&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
[self reportOTTWithDict:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)reportOTTWithDict:(NSDictionary *)ottDict&lt;br /&gt;
{&lt;br /&gt;
[self.nielsenSDK updateOTT:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification === &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChanged(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func handleRouteChanged(_ notification: Notification) {&lt;br /&gt;
var currentStatus: [String: String] = [&amp;quot;ottStatus&amp;quot;: &amp;quot;0&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
let session = AVAudioSession.sharedInstance()&lt;br /&gt;
let currentRoute = session.currentRoute&lt;br /&gt;
for outputPort in currentRoute.outputs {&lt;br /&gt;
if outputPort.portType == AVAudioSessionPortAirPlay {&lt;br /&gt;
currentStatus[&amp;quot;ottStatus&amp;quot;] = &amp;quot;1&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceID&amp;quot;] = outputPort.uid&lt;br /&gt;
&lt;br /&gt;
if outputPort.portName == &amp;quot;AirPlay&amp;quot; {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if outputPort.portName.contains(&amp;quot;Apple TV&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;appleTV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if outputPort.uid.hasSuffix(&amp;quot;airplay&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else if outputPort.uid.hasSuffix(&amp;quot;screen&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;mirroring&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
self.reportOTTUpdate(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK===&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func reportOTTUpdate(_ ottDict: [String: String]) {&lt;br /&gt;
if let nielsenSdk = self.nielsenAppApi {&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories:&lt;br /&gt;
* '''Basic''' - To show the functionality of the Nielsen Simplified API using a standard no-frills player.&lt;br /&gt;
** [[Swift Basic Sample|Swift 4.0 Sample]]&lt;br /&gt;
** [[Objective-c Basic example|Objective-C Sample]]&lt;br /&gt;
** [[Android Basic example|Android Studio Example]]&lt;br /&gt;
&lt;br /&gt;
* '''Advanced''' - Nielsen Simplified API integrated into a custom video player.&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Swift 4.0 Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Objective-C Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Java/Android Studio Sample]&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6515</id>
		<title>DCR Poland Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6515"/>
		<updated>2023-09-13T12:51:44Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 30px;&amp;quot; |&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''sfcode''' || Environment that the SDK must point to || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed below:&lt;br /&gt;
&lt;br /&gt;
[[ Nielsen Digital Measurement and_iOS17 or TVOS17 |Nielsen Digital Measurement and_iOS17 or TVOS17]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
&lt;br /&gt;
* The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Optional; automatically detected in SDK 6.0.0.4 and above || Nielsen Sample App&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
* &amp;quot;pl&amp;quot; &lt;br /&gt;
|| Nielsen-specified || Yes || pl&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;INFO&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': DO NOT activate the Debug flag in a production environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift  = &lt;br /&gt;
Swift 4.0 Example:&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample code using AVPlayer.&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NielsenInit.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NielsenInit&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate&lt;br /&gt;
{    &lt;br /&gt;
    NSDictionary *appInformation = @{ @&amp;quot;appid&amp;quot;: @&amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                            @&amp;quot;appversion&amp;quot;: @&amp;quot;1.0&amp;quot;,&lt;br /&gt;
                            @&amp;quot;sfcode&amp;quot;: @&amp;quot;pl&amp;quot;,&lt;br /&gt;
                            @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;, };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NielsenInit.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NielsenInit : NSObject&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sample Code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Payload ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** 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.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
    &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;C77664&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Program S2, E3&amp;quot;,&lt;br /&gt;
    &amp;quot;isfullepisode&amp;quot;: &amp;quot;Yes&amp;quot;,&lt;br /&gt;
    &amp;quot;program&amp;quot;: &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
    &amp;quot;airdate&amp;quot;: &amp;quot;20171020 10:05:00&amp;quot;,&lt;br /&gt;
    &amp;quot;adloadtype&amp;quot;: &amp;quot;2&amp;quot;,&lt;br /&gt;
    &amp;quot;segB&amp;quot;: &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
    &amp;quot;segC&amp;quot;: &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * channelInfo = @ {&lt;br /&gt;
    @ &amp;quot;channelName&amp;quot;: @ &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
        @ &amp;quot;assetid&amp;quot;: @ &amp;quot;C77664&amp;quot;,&lt;br /&gt;
        @ &amp;quot;title&amp;quot;: @ &amp;quot;S2,E3&amp;quot;,&lt;br /&gt;
        @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
        @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
        @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
        @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20180120 10:00:00&amp;quot;,&lt;br /&gt;
        @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;,&lt;br /&gt;
        @ &amp;quot;segB&amp;quot;: @ &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
        @ &amp;quot;segC&amp;quot;: @ &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== ChannelName metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode / clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type || type of asset	|| &amp;quot;content&amp;quot; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| unique ID assigned to asset (max 64 characters; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) || custom (no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| (string) name of program (max 254 characters)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| (string) episode title (max 254 characters)	|| custom - no backslash allowed in string (because of 3rd party data processing) || ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| (int) length of content in seconds	|| 86400 seconds for live stream. For Event-Livestreams planned length. For VoD video length||	✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear TV. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;	||	YYYY-MM-DDTHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS+xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS-xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDD HH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
MM-DD-YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
MM/DD/YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
 (pass beginning of epoch if unknown)&lt;br /&gt;
	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag	||	&amp;quot;y&amp;quot;- full episode, &amp;quot;n&amp;quot;- non full episode	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads ||  ✓&lt;br /&gt;
|-&lt;br /&gt;
| progen || program genre	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| crossId1 || standard episode ID	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| clientid	|| &lt;br /&gt;
parent ID – value is automatically populated through provided AppID.&amp;lt;br/&amp;gt;&lt;br /&gt;
In order to override the brand configured to the AppID, pass parent &amp;lt;br/&amp;gt;&lt;br /&gt;
value here and the sub-brand ID associated to that brand in the subbrand &amp;lt;br/&amp;gt;&lt;br /&gt;
key (e.g. multiple brands in App)	&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen	&lt;br /&gt;
||&lt;br /&gt;
|-&lt;br /&gt;
| subbrand	|| vcid/sub-brand ID – value is automatically populated through provided&amp;lt;br/&amp;gt;&lt;br /&gt;
AppID. In order to override the sub-brand configured to the AppID, value can &amp;lt;br/&amp;gt;&lt;br /&gt;
be passed here (e.g. multiple sub-brands in App)&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen&lt;br /&gt;
||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of ad	|| &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt;||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom &amp;lt;br&amp;gt;(no [[Special Characters]])	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let adMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;123456&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * adMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Nielsen API Documentation ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; to pass the channel descriptor information through channelName parameter when the user taps the '''Play''' button on the player. Pass in channelName metadata as described above.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenApi play:([NSDictionary *channel loadChannelInfo)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.play(channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
Call to inform SDK about asset being played. Pass in metadata as described here [[#Configure Payload]], [[#Content Metadata]]&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
Call to inform Nielsen SDK about position in video asset (for VOD pass second within video, for livestreams UTC timestamp in seconds).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi playheadPosition:secondsAsInt];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.playheadPosition(secondsAsInt)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
Call to indicate interruption during playback, e.g. pause. (more on interruption scenarios here: [[#Interruptions during playback]] )&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
Call when content finished playback and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
[[File:appsdkTimeline-DCR.png|icon|link=]]&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
nielsenApi = NielsenInit.createNielsenApi(delegate: self);&lt;br /&gt;
data = loadStaticMetadata();&lt;br /&gt;
nielsenApi.loadMetadata(self.data);&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName)&amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – SDK instance exits from Processing state when this API is called.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== API Call Sequence ==&lt;br /&gt;
=== Use Case 1: Content has no Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use Case 2: Content has Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad=123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after the content is paused (ad starts)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Always call stop irrespective of postroll is followed or not&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Pre-Certification Checklists ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are three primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Limit Ad Tracking'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#Legacy_Opt-out|Legacy Opt-out]]''' - Direct call to SDK; used only for older versions of Nielsen iOS SDK (&amp;lt; 5.1.1.18)&lt;br /&gt;
# '''[[#App_Level_Opt_Out|App Level Opt-Out]]''' - Where [https://developer.apple.com/documentation/adsupport Ad Framework] cannot be leveraged&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS '''SDK Versions 5.1.1.18 and above'''.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's ''Limit Ad Tracking'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Limit Ad Tracking&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
=== Legacy Opt-out ===&lt;br /&gt;
The ''Legacy opt-out'' method is only necessary for Nielsen iOS '''SDK versions less than 5.1.1.18'''.&lt;br /&gt;
&lt;br /&gt;
Nielsen iOS SDK 5.1.1.17 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.&lt;br /&gt;
&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the legacy Nielsen opt-out URL via [[optOutURL]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=swift&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt-out example code ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-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&lt;br /&gt;
&lt;br /&gt;
=== First Party ID (FPID)===&lt;br /&gt;
- The broadcaster must enableFPID in the initialization settings which is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; depending on user consent. This is to be set by the broadcaster when initializing our SDK.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The &amp;lt;code&amp;gt;enableFpid&amp;lt;/code&amp;gt; flag is needed to enable/disable FPID usage for the AppID. The default value for this flag is true. If this flag is changed from true to false, then the AppSDK should wipe out the stored FPID and use a blank value for the FPID parameter in all the pings.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Generated FPID value is stored in the persistent memory until the application is uninstalled from a device or until FPID is wiped out or until it is expired.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The default value for this parameter is 180 days. Once this timeout is reached, the FPID should be regenerated.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Example: disable FPID during init call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;, // sfcode for Poland&lt;br /&gt;
            &amp;quot;enableFpid&amp;quot;: &amp;quot;false&amp;quot; //false = FPID is disabled, true= FPID is enabled&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot; // only for debug builds and see the Nielsen logs&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required Privacy Links ===&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
'''&amp;quot;Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://priv-policy.imrworldwide.com/priv/mobile/pl/pl/optout.html for more information&amp;quot;'''&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
    &lt;br /&gt;
    //Setting background image&lt;br /&gt;
    UIImage *backgroundImage = [UIImage imageNamed:@&amp;quot;new_ios_bg.png&amp;quot;];&lt;br /&gt;
    UIImageView *backgroundImageView=[[UIImageView alloc]initWithFrame:self.view.frame];&lt;br /&gt;
    backgroundImageView.image=backgroundImage;&lt;br /&gt;
    [self.view insertSubview:backgroundImageView atIndex:0];&lt;br /&gt;
&lt;br /&gt;
    self.nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&lt;br /&gt;
    //Initialising the webview&lt;br /&gt;
    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];&lt;br /&gt;
    _wkwebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];&lt;br /&gt;
    _wkwebView.navigationDelegate = self;&lt;br /&gt;
&lt;br /&gt;
     //Getting the optPut URL from SDK&lt;br /&gt;
    NSURL *nsurl=[NSURL URLWithString:[self.nielsenApi optOutURL]];&lt;br /&gt;
&lt;br /&gt;
    //Setting url request in webview&lt;br /&gt;
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];&lt;br /&gt;
&lt;br /&gt;
     //Setting url request in webview&lt;br /&gt;
    [_wkwebView loadRequest:nsrequest];&lt;br /&gt;
&lt;br /&gt;
      //Adding webview to the controller view &lt;br /&gt;
    [self.view addSubview:_wkwebView];   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) {&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== App Level Opt Out ===&lt;br /&gt;
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:&lt;br /&gt;
* Implement the UIWebView delegate method to open the Nielsen Privacy web page&lt;br /&gt;
* Capture user's selection&lt;br /&gt;
* Pass the selection back to the SDK via the &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Capture and forward user selection ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType&lt;br /&gt;
{&lt;br /&gt;
    NSString *command = [NSString stringWithFormat:@&amp;quot;%@&amp;quot;,request.URL];&lt;br /&gt;
    if ([command isEqualToString:kNielsenWebClose]) {&lt;br /&gt;
        // Close the WebView&lt;br /&gt;
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];&lt;br /&gt;
        return NO;&lt;br /&gt;
    }&lt;br /&gt;
    // Retrieve next URL if it’s not opt-in/out selection&lt;br /&gt;
    return (![nAppApiObject userOptOut:command]);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -&amp;gt; Bool {&lt;br /&gt;
&lt;br /&gt;
        let command = request.url?.absoluteString&lt;br /&gt;
        if  command ==  &amp;quot;kNielsenWebClose&amp;quot;{&lt;br /&gt;
&lt;br /&gt;
            self.perform(#selector(closeOptOutView), with: nil, afterDelay: 0)&lt;br /&gt;
&lt;br /&gt;
            return false&lt;br /&gt;
        }    &lt;br /&gt;
        return NielsenAppApi.optOutURL&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== AirPlay ==&lt;br /&gt;
To implement OTT measurement, report OTT changes to the SDK using public API interface: [[updateOTT]]&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;AVAudioSessionPortDescription&amp;lt;/code&amp;gt; has the following values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-airplay &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-screen&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For iOS 11+ some parameters like name and UID have different values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = AirPlay; UID = 0eb63aae-5915-45f1-b0f7-0102a0e50d53 &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = 4335E8A9-1C0A-4251-9000-28CA5FA2F3CF-192731714653291-screen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following code snipped is suggested for AirPlay / mirroring detection on iOS devices.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
– (void)updateOTT:(id)ottInfo;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)handleRouteChanged:(NSNotification *)notification&lt;br /&gt;
{&lt;br /&gt;
NSMutableDictionary *ottDict = [NSMutableDictionary dictionaryWithDictionary: @{@&amp;quot;ottStatus&amp;quot;: @&amp;quot;0&amp;quot;}];&lt;br /&gt;
&lt;br /&gt;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];&lt;br /&gt;
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;&lt;br /&gt;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs) {&lt;br /&gt;
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]) {&lt;br /&gt;
ottDict[@&amp;quot;ottStatus&amp;quot;] = @&amp;quot;1&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceID&amp;quot;] = outputPort.UID;&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.portName isEqualToString:@&amp;quot;AirPlay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if ([outputPort.portName containsString:@&amp;quot;Apple TV&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;appleTV&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.UID hasSuffix:@&amp;quot;airplay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else if ([outputPort.UID hasSuffix:@&amp;quot;screen&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;mirroring&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
[self reportOTTWithDict:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)reportOTTWithDict:(NSDictionary *)ottDict&lt;br /&gt;
{&lt;br /&gt;
[self.nielsenSDK updateOTT:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification === &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChanged(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func handleRouteChanged(_ notification: Notification) {&lt;br /&gt;
var currentStatus: [String: String] = [&amp;quot;ottStatus&amp;quot;: &amp;quot;0&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
let session = AVAudioSession.sharedInstance()&lt;br /&gt;
let currentRoute = session.currentRoute&lt;br /&gt;
for outputPort in currentRoute.outputs {&lt;br /&gt;
if outputPort.portType == AVAudioSessionPortAirPlay {&lt;br /&gt;
currentStatus[&amp;quot;ottStatus&amp;quot;] = &amp;quot;1&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceID&amp;quot;] = outputPort.uid&lt;br /&gt;
&lt;br /&gt;
if outputPort.portName == &amp;quot;AirPlay&amp;quot; {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if outputPort.portName.contains(&amp;quot;Apple TV&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;appleTV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if outputPort.uid.hasSuffix(&amp;quot;airplay&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else if outputPort.uid.hasSuffix(&amp;quot;screen&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;mirroring&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
self.reportOTTUpdate(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK===&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func reportOTTUpdate(_ ottDict: [String: String]) {&lt;br /&gt;
if let nielsenSdk = self.nielsenAppApi {&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories:&lt;br /&gt;
* '''Basic''' - To show the functionality of the Nielsen Simplified API using a standard no-frills player.&lt;br /&gt;
** [[Swift Basic Sample|Swift 4.0 Sample]]&lt;br /&gt;
** [[Objective-c Basic example|Objective-C Sample]]&lt;br /&gt;
** [[Android Basic example|Android Studio Example]]&lt;br /&gt;
&lt;br /&gt;
* '''Advanced''' - Nielsen Simplified API integrated into a custom video player.&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Swift 4.0 Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Objective-C Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Java/Android Studio Sample]&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6514</id>
		<title>DCR Poland Video iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Poland_Video_iOS_SDK&amp;diff=6514"/>
		<updated>2023-09-13T12:46:19Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Special Notes regarding iOS14 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To start using the App SDK, the following items are required:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 30px;&amp;quot; |&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''sfcode''' || Environment that the SDK must point to || Contact Nielsen&lt;br /&gt;
|-&lt;br /&gt;
|| ☑ || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS17 ==&lt;br /&gt;
&lt;br /&gt;
Beginning with iOS/tvOS 17, Apple is adding several requirements for App developers around tracking, use of Identifier For Advertisers (IDFA), and certain system APIs as detailed here&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
&lt;br /&gt;
* The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique id for the application assigned by Nielsen. It is GUID data type.|| Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application || Client-defined || Optional; automatically detected in SDK 6.0.0.4 and above || Nielsen Sample App&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
* &amp;quot;pl&amp;quot; &lt;br /&gt;
|| Nielsen-specified || Yes || pl&lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Optional || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;INFO&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': DO NOT activate the Debug flag in a production environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift  = &lt;br /&gt;
Swift 4.0 Example:&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample code using AVPlayer.&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPlayerViewControllerDelegate  {&lt;br /&gt;
&lt;br /&gt;
// your code//    &lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
        //Getting the instance of NielsenApi&lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Objective C = &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NielsenInit.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NielsenInit&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate&lt;br /&gt;
{    &lt;br /&gt;
    NSDictionary *appInformation = @{ @&amp;quot;appid&amp;quot;: @&amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                            @&amp;quot;appversion&amp;quot;: @&amp;quot;1.0&amp;quot;,&lt;br /&gt;
                            @&amp;quot;sfcode&amp;quot;: @&amp;quot;pl&amp;quot;,&lt;br /&gt;
                            @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;, };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NielsenInit.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NielsenInit : NSObject&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sample Code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS and Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Payload ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** 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.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
    &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;C77664&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Program S2, E3&amp;quot;,&lt;br /&gt;
    &amp;quot;isfullepisode&amp;quot;: &amp;quot;Yes&amp;quot;,&lt;br /&gt;
    &amp;quot;program&amp;quot;: &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
    &amp;quot;airdate&amp;quot;: &amp;quot;20171020 10:05:00&amp;quot;,&lt;br /&gt;
    &amp;quot;adloadtype&amp;quot;: &amp;quot;2&amp;quot;,&lt;br /&gt;
    &amp;quot;segB&amp;quot;: &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
    &amp;quot;segC&amp;quot;: &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * channelInfo = @ {&lt;br /&gt;
    @ &amp;quot;channelName&amp;quot;: @ &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
        @ &amp;quot;assetid&amp;quot;: @ &amp;quot;C77664&amp;quot;,&lt;br /&gt;
        @ &amp;quot;title&amp;quot;: @ &amp;quot;S2,E3&amp;quot;,&lt;br /&gt;
        @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
        @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
        @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
        @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20180120 10:00:00&amp;quot;,&lt;br /&gt;
        @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;,&lt;br /&gt;
        @ &amp;quot;segB&amp;quot;: @ &amp;quot;CustomSegmentValueB&amp;quot;, //optional&lt;br /&gt;
        @ &amp;quot;segC&amp;quot;: @ &amp;quot;CustomSegmentValueC&amp;quot;, //optional&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== ChannelName metadata ===&lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode / clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type || type of asset	|| &amp;quot;content&amp;quot; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| unique ID assigned to asset (max 64 characters; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) || custom (no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| (string) name of program (max 254 characters)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| (string) episode title (max 254 characters)	|| custom - no backslash allowed in string (because of 3rd party data processing) || ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| (int) length of content in seconds	|| 86400 seconds for live stream. For Event-Livestreams planned length. For VoD video length||	✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear TV. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;	||	YYYY-MM-DDTHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS+xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYY-MM-DDTHH:MI:SS-xx:xx&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDDHH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
YYYYMMDD HH:MI:SS&amp;lt;br&amp;gt;&lt;br /&gt;
MM-DD-YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
MM/DD/YYYY&amp;lt;br&amp;gt;&lt;br /&gt;
 (pass beginning of epoch if unknown)&lt;br /&gt;
	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag	||	&amp;quot;y&amp;quot;- full episode, &amp;quot;n&amp;quot;- non full episode	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;&amp;quot;2&amp;quot;&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads ||  ✓&lt;br /&gt;
|-&lt;br /&gt;
| progen || program genre	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| segC || custom segment	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| crossId1 || standard episode ID	||	custom	||&lt;br /&gt;
|-&lt;br /&gt;
| clientid	|| &lt;br /&gt;
parent ID – value is automatically populated through provided AppID.&amp;lt;br/&amp;gt;&lt;br /&gt;
In order to override the brand configured to the AppID, pass parent &amp;lt;br/&amp;gt;&lt;br /&gt;
value here and the sub-brand ID associated to that brand in the subbrand &amp;lt;br/&amp;gt;&lt;br /&gt;
key (e.g. multiple brands in App)	&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen	&lt;br /&gt;
||&lt;br /&gt;
|-&lt;br /&gt;
| subbrand	|| vcid/sub-brand ID – value is automatically populated through provided&amp;lt;br/&amp;gt;&lt;br /&gt;
AppID. In order to override the sub-brand configured to the AppID, value can &amp;lt;br/&amp;gt;&lt;br /&gt;
be passed here (e.g. multiple sub-brands in App)&lt;br /&gt;
||&lt;br /&gt;
provided by Nielsen&lt;br /&gt;
||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of ad	|| &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt;||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom &amp;lt;br&amp;gt;(no [[Special Characters]])	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
let adMetadata = [&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    &amp;quot;assetid&amp;quot;: &amp;quot;123456&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt; &lt;br /&gt;
NSDictionary * adMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;preroll&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Nielsen API Documentation ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; to pass the channel descriptor information through channelName parameter when the user taps the '''Play''' button on the player. Pass in channelName metadata as described above.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenApi play:([NSDictionary *channel loadChannelInfo)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.play(channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
Call to inform SDK about asset being played. Pass in metadata as described here [[#Configure Payload]], [[#Content Metadata]]&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
Call to inform Nielsen SDK about position in video asset (for VOD pass second within video, for livestreams UTC timestamp in seconds).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi playheadPosition:secondsAsInt];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.playheadPosition(secondsAsInt)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
Call to indicate interruption during playback, e.g. pause. (more on interruption scenarios here: [[#Interruptions during playback]] )&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
Call when content finished playback and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi?.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
[[File:appsdkTimeline-DCR.png|icon|link=]]&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
nielsenApi = NielsenInit.createNielsenApi(delegate: self);&lt;br /&gt;
data = loadStaticMetadata();&lt;br /&gt;
nielsenApi.loadMetadata(self.data);&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName)&amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – SDK instance exits from Processing state when this API is called.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== API Call Sequence ==&lt;br /&gt;
=== Use Case 1: Content has no Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;vid345-67483&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;: &amp;quot;ProgramName&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
  ...&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Use Case 2: Content has Advertisements ===&lt;br /&gt;
Call [[play()]] with channelName JSON as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;channelName&amp;quot;: &amp;quot;TheMovieTitle&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad=123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenApi.play(channelName); &amp;lt;/code&amp;gt; || // channelName now automatically generated by Nielsen SDK&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after the content is paused (ad starts)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;6&amp;quot; | Midroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // App moves to background(midroll pauses) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // App moves to foreground (midroll resumes) &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead while the midroll ad is being played &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Content (End of stream) || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Always call stop irrespective of postroll is followed or not&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenApi.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;nielsenApi.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenApi.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock (Video players only, not for Audio players)&lt;br /&gt;
* App going in the Background/Foreground (Video players only, not for Audio players)&lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Pre-Certification Checklists ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are three primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Limit Ad Tracking'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#Legacy_Opt-out|Legacy Opt-out]]''' - Direct call to SDK; used only for older versions of Nielsen iOS SDK (&amp;lt; 5.1.1.18)&lt;br /&gt;
# '''[[#App_Level_Opt_Out|App Level Opt-Out]]''' - Where [https://developer.apple.com/documentation/adsupport Ad Framework] cannot be leveraged&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS '''SDK Versions 5.1.1.18 and above'''.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's ''Limit Ad Tracking'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Limit Ad Tracking&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
=== Legacy Opt-out ===&lt;br /&gt;
The ''Legacy opt-out'' method is only necessary for Nielsen iOS '''SDK versions less than 5.1.1.18'''.&lt;br /&gt;
&lt;br /&gt;
Nielsen iOS SDK 5.1.1.17 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.&lt;br /&gt;
&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the legacy Nielsen opt-out URL via [[optOutURL]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=swift&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt-out example code ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-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&lt;br /&gt;
&lt;br /&gt;
=== First Party ID (FPID)===&lt;br /&gt;
- The broadcaster must enableFPID in the initialization settings which is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; depending on user consent. This is to be set by the broadcaster when initializing our SDK.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The &amp;lt;code&amp;gt;enableFpid&amp;lt;/code&amp;gt; flag is needed to enable/disable FPID usage for the AppID. The default value for this flag is true. If this flag is changed from true to false, then the AppSDK should wipe out the stored FPID and use a blank value for the FPID parameter in all the pings.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Generated FPID value is stored in the persistent memory until the application is uninstalled from a device or until FPID is wiped out or until it is expired.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- The default value for this parameter is 180 days. Once this timeout is reached, the FPID should be regenerated.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Example: disable FPID during init call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;sfcode&amp;quot;: &amp;quot;pl&amp;quot;, // sfcode for Poland&lt;br /&gt;
            &amp;quot;enableFpid&amp;quot;: &amp;quot;false&amp;quot; //false = FPID is disabled, true= FPID is enabled&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot; // only for debug builds and see the Nielsen logs&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required Privacy Links ===&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
'''&amp;quot;Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://priv-policy.imrworldwide.com/priv/mobile/pl/pl/optout.html for more information&amp;quot;'''&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
    &lt;br /&gt;
    //Setting background image&lt;br /&gt;
    UIImage *backgroundImage = [UIImage imageNamed:@&amp;quot;new_ios_bg.png&amp;quot;];&lt;br /&gt;
    UIImageView *backgroundImageView=[[UIImageView alloc]initWithFrame:self.view.frame];&lt;br /&gt;
    backgroundImageView.image=backgroundImage;&lt;br /&gt;
    [self.view insertSubview:backgroundImageView atIndex:0];&lt;br /&gt;
&lt;br /&gt;
    self.nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
&lt;br /&gt;
    //Initialising the webview&lt;br /&gt;
    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];&lt;br /&gt;
    _wkwebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];&lt;br /&gt;
    _wkwebView.navigationDelegate = self;&lt;br /&gt;
&lt;br /&gt;
     //Getting the optPut URL from SDK&lt;br /&gt;
    NSURL *nsurl=[NSURL URLWithString:[self.nielsenApi optOutURL]];&lt;br /&gt;
&lt;br /&gt;
    //Setting url request in webview&lt;br /&gt;
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];&lt;br /&gt;
&lt;br /&gt;
     //Setting url request in webview&lt;br /&gt;
    [_wkwebView loadRequest:nsrequest];&lt;br /&gt;
&lt;br /&gt;
      //Adding webview to the controller view &lt;br /&gt;
    [self.view addSubview:_wkwebView];   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    &lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)&lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) {&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== App Level Opt Out ===&lt;br /&gt;
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:&lt;br /&gt;
* Implement the UIWebView delegate method to open the Nielsen Privacy web page&lt;br /&gt;
* Capture user's selection&lt;br /&gt;
* Pass the selection back to the SDK via the &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Capture and forward user selection ====&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType&lt;br /&gt;
{&lt;br /&gt;
    NSString *command = [NSString stringWithFormat:@&amp;quot;%@&amp;quot;,request.URL];&lt;br /&gt;
    if ([command isEqualToString:kNielsenWebClose]) {&lt;br /&gt;
        // Close the WebView&lt;br /&gt;
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];&lt;br /&gt;
        return NO;&lt;br /&gt;
    }&lt;br /&gt;
    // Retrieve next URL if it’s not opt-in/out selection&lt;br /&gt;
    return (![nAppApiObject userOptOut:command]);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -&amp;gt; Bool {&lt;br /&gt;
&lt;br /&gt;
        let command = request.url?.absoluteString&lt;br /&gt;
        if  command ==  &amp;quot;kNielsenWebClose&amp;quot;{&lt;br /&gt;
&lt;br /&gt;
            self.perform(#selector(closeOptOutView), with: nil, afterDelay: 0)&lt;br /&gt;
&lt;br /&gt;
            return false&lt;br /&gt;
        }    &lt;br /&gt;
        return NielsenAppApi.optOutURL&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes &amp;lt;code&amp;gt;userOptOut&amp;lt;/code&amp;gt; with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.&lt;br /&gt;
**&amp;lt;code&amp;gt;[nAppApiObject userOptOut:command]&amp;lt;/code&amp;gt; passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== AirPlay ==&lt;br /&gt;
To implement OTT measurement, report OTT changes to the SDK using public API interface: [[updateOTT]]&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;AVAudioSessionPortDescription&amp;lt;/code&amp;gt; has the following values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-airplay &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = DC:56:E7:53:72:85-screen&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For iOS 11+ some parameters like name and UID have different values:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
AirPlay: type = AirPlay; name = AirPlay; UID = 0eb63aae-5915-45f1-b0f7-0102a0e50d53 &amp;lt;br&amp;gt;&lt;br /&gt;
Mirroring: type = AirPlay; name = Apple TV 4K; UID = 4335E8A9-1C0A-4251-9000-28CA5FA2F3CF-192731714653291-screen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following code snipped is suggested for AirPlay / mirroring detection on iOS devices.&lt;br /&gt;
&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
– (void)updateOTT:(id)ottInfo;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)handleRouteChanged:(NSNotification *)notification&lt;br /&gt;
{&lt;br /&gt;
NSMutableDictionary *ottDict = [NSMutableDictionary dictionaryWithDictionary: @{@&amp;quot;ottStatus&amp;quot;: @&amp;quot;0&amp;quot;}];&lt;br /&gt;
&lt;br /&gt;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];&lt;br /&gt;
AVAudioSessionRouteDescription *currentRoute = audioSession.currentRoute;&lt;br /&gt;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs) {&lt;br /&gt;
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]) {&lt;br /&gt;
ottDict[@&amp;quot;ottStatus&amp;quot;] = @&amp;quot;1&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName;&lt;br /&gt;
ottDict[@&amp;quot;ottDeviceID&amp;quot;] = outputPort.UID;&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.portName isEqualToString:@&amp;quot;AirPlay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if ([outputPort.portName containsString:@&amp;quot;Apple TV&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;appleTV&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottDevice&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ([outputPort.UID hasSuffix:@&amp;quot;airplay&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;airplay&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else if ([outputPort.UID hasSuffix:@&amp;quot;screen&amp;quot;]) {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;mirroring&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
ottDict[@&amp;quot;ottType&amp;quot;] = @&amp;quot;other&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
[self reportOTTWithDict:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)reportOTTWithDict:(NSDictionary *)ottDict&lt;br /&gt;
{&lt;br /&gt;
[self.nielsenSDK updateOTT:ottDict];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Subscribe to AVAudioSessionRouteChangeNotification === &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChanged(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Handle AVAudioSessionRouteChangeNotification and prepare OTT dictionary:===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func handleRouteChanged(_ notification: Notification) {&lt;br /&gt;
var currentStatus: [String: String] = [&amp;quot;ottStatus&amp;quot;: &amp;quot;0&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
let session = AVAudioSession.sharedInstance()&lt;br /&gt;
let currentRoute = session.currentRoute&lt;br /&gt;
for outputPort in currentRoute.outputs {&lt;br /&gt;
if outputPort.portType == AVAudioSessionPortAirPlay {&lt;br /&gt;
currentStatus[&amp;quot;ottStatus&amp;quot;] = &amp;quot;1&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceModel&amp;quot;] = outputPort.portName&lt;br /&gt;
currentStatus[&amp;quot;ottDeviceID&amp;quot;] = outputPort.uid&lt;br /&gt;
&lt;br /&gt;
if outputPort.portName == &amp;quot;AirPlay&amp;quot; {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
if outputPort.portName.contains(&amp;quot;Apple TV&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;appleTV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottDevice&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if outputPort.uid.hasSuffix(&amp;quot;airplay&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;airplay&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else if outputPort.uid.hasSuffix(&amp;quot;screen&amp;quot;) {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;mirroring&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
currentStatus[&amp;quot;ottType&amp;quot;] = &amp;quot;other&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// report OTT status update to Nielsen SDK&lt;br /&gt;
self.reportOTTUpdate(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Report OTT update to the Nielsen SDK===&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;Swift&amp;quot;&amp;gt;&lt;br /&gt;
func reportOTTUpdate(_ ottDict: [String: String]) {&lt;br /&gt;
if let nielsenSdk = self.nielsenAppApi {&lt;br /&gt;
nielsenSdk.updateOTT(currentStatus)&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories:&lt;br /&gt;
* '''Basic''' - To show the functionality of the Nielsen Simplified API using a standard no-frills player.&lt;br /&gt;
** [[Swift Basic Sample|Swift 4.0 Sample]]&lt;br /&gt;
** [[Objective-c Basic example|Objective-C Sample]]&lt;br /&gt;
** [[Android Basic example|Android Studio Example]]&lt;br /&gt;
&lt;br /&gt;
* '''Advanced''' - Nielsen Simplified API integrated into a custom video player.&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Swift 4.0 Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Objective-C Sample]&lt;br /&gt;
** [https://engineeringportal.nielsen.com/docs/Special:Downloads Java/Android Studio Sample]&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_Google_AMP_Cloud_API&amp;diff=6513</id>
		<title>DCR Italy Static Google AMP Cloud API</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_Static_Google_AMP_Cloud_API&amp;diff=6513"/>
		<updated>2023-09-08T11:38:11Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Configure Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
This guide will show you how to enable Digital Content Ratings (DCR) Static measurement on Google AMP.&lt;br /&gt;
&lt;br /&gt;
== Import AMP Analytics Javascript Library ==&lt;br /&gt;
If you have not already, you will need to import the AMP JS library in the &amp;lt;code&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/code&amp;gt; of your webpage in order to make an AMP page:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script async src=&amp;quot;https://cdn.ampproject.org/v0.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, please ensure that the following line is included in the &amp;lt;code&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/code&amp;gt; of the webpage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;script async custom-element=&amp;quot;amp-analytics&amp;quot; src=&amp;quot;https://cdn.ampproject.org/v0/amp-analytics-0.1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': AMP pages require all traffic to be using HTTPS, including the webpage itself&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Specify the Analytics Provider ==&lt;br /&gt;
DCR measurement can be added to your AMP pages through the AMP-Analytics element:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;amp-analytics type=&amp;quot;nielsen&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Add Nielsen DCR Tags here --&amp;gt;&lt;br /&gt;
&amp;lt;/amp-analytics&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information on the Analytics type, you can refer to the [https://www.ampproject.org/docs/analytics/analytics-vendors Analytics vendors] section of Google's AMP Developer Documentation.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
You will need to match the metadata fields on your AMP page with those of your non-AMP page.&lt;br /&gt;
&lt;br /&gt;
=== Metadata Keys ===&lt;br /&gt;
The Nielsen reserved keys are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !! Example Value !! Required&lt;br /&gt;
|-&lt;br /&gt;
| apid || unique ID assigned by Nielsen || &amp;lt;code&amp;gt;XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| prefix  || URL prefix to allow EU data collection|| eu-  || ✓&lt;br /&gt;
|-&lt;br /&gt;
| apv || current version of the Nielsen implementation || &amp;lt;code&amp;gt;1.0&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| apn || name of the website || &amp;lt;code&amp;gt;My AMP Website&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| section || section of the site to be measured || &amp;lt;code&amp;gt;EntityName_AMP&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| segA || custom segment to be used to break out reporting || &amp;lt;code&amp;gt;NA&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| segB || custom segment to be used to break out reporting || &amp;lt;code&amp;gt;NA&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| segC || Reserved custom segment for Google AMP || &amp;lt;code&amp;gt;Google AMP&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The values passed through the Nielsen keys will determine the breakouts you will see in reporting. If you decide not to use custom segments A and B, then you do not need to pass a value in these keys. It is suggested you use the same segments used in non-AMP pages.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': The value for the 'apid' you pass for AMP measurement should not include the 'P' prefix that is otherwise present on other SDK-related implementations&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Metadata for Reporting ===&lt;br /&gt;
You can reference the table to determine how the metadata you pass is used to define your reporting structure:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Reporting Level !! Key !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Brand/Sub-brand || apid || brand and sub-brand are determined by assigned App ID passed during initialization&lt;br /&gt;
|-&lt;br /&gt;
| Section || section || section or category for the AMP page&lt;br /&gt;
|-&lt;br /&gt;
| Custom Segment A || segA || available segment for custom reporting. Custom segments will roll into the sub-brand&lt;br /&gt;
|-&lt;br /&gt;
| Custom Segment B || segB || available segment for custom reporting. Custom segments will roll into the sub-brand&lt;br /&gt;
|-&lt;br /&gt;
| Custom Segment C || segC || Custom segment C is reserved for reporting ‘Google AMP’. The Google AMP custom segment will be available under sub-brand and will include the total metrics for all your AMP pages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you would like your AMP pages to report into the same reporting structure as your website, we recommend passing the same dynamic metadata in Section, Custom Segment A, and Custom Segment B as you are on your website. This way your AMP pageviews contribute to those aggregations.&lt;br /&gt;
&lt;br /&gt;
== Example Implementation ==&lt;br /&gt;
The below is an example implementation of Nielsen measurement on an AMP page:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&amp;lt;amp-analytics type=&amp;quot;nielsen&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;script type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;vars&amp;quot;: {&lt;br /&gt;
        &amp;quot;apid&amp;quot;: &amp;quot;XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot;,&lt;br /&gt;
        &amp;quot;prefix&amp;quot;: &amp;quot;eu-&amp;quot;,&lt;br /&gt;
        &amp;quot;apv&amp;quot;: &amp;quot;1.0&amp;quot;,&lt;br /&gt;
        &amp;quot;apn&amp;quot;: &amp;quot;My AMP Website&amp;quot;,&lt;br /&gt;
        &amp;quot;section&amp;quot;: &amp;quot;EntityName_AMP&amp;quot;,&lt;br /&gt;
        &amp;quot;segA&amp;quot;: &amp;quot;NA&amp;quot;,&lt;br /&gt;
        &amp;quot;segB&amp;quot;: &amp;quot;NA&amp;quot;,&lt;br /&gt;
        &amp;quot;segC&amp;quot;: &amp;quot;Google AMP&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/amp-analytics&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find more information about dynamic variables on [https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md#page-and-content Google's AMP documentation].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': append &amp;lt;code&amp;gt;#development=1&amp;lt;/code&amp;gt; at the end of your URL to see AMP debug logs in the console. This can be helpful when troubleshooting&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Privacy Policy ==&lt;br /&gt;
Nielsen uses cookies for browser measurement. In order to comply with our privacy restrictions, we ask that you make a link to our Digital Privacy Policy available on your site. You can find our privacy policy here: https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6453</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6453"/>
		<updated>2023-07-17T07:57:16Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Ad Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  let adMetadata = [&lt;br /&gt;
        &amp;quot;assetid&amp;quot; : &amp;quot;unique_postroll_ad_id&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; : &amp;quot;preroll&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6452</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6452"/>
		<updated>2023-07-17T07:56:51Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Ad Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  let adMetadata = [&lt;br /&gt;
        &amp;quot;assetid&amp;quot; : &amp;quot;unique_postroll_ad_id&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; : &amp;quot;preroll&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6451</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6451"/>
		<updated>2023-07-17T07:56:24Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Ad Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  let adMetadata = [&lt;br /&gt;
        &amp;quot;assetid&amp;quot; : &amp;quot;unique_postroll_ad_id&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; : &amp;quot;postroll&amp;quot;&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6450</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6450"/>
		<updated>2023-07-17T07:55:36Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Ad Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6449</id>
		<title>DCR Italy AUDIO Browser SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6449"/>
		<updated>2023-07-17T07:53:40Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings ([[DCR &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:&lt;br /&gt;
*Site launch events and how long page is viewed&lt;br /&gt;
*Time of viewing a sub section / page.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To get started, an App ID is needed. The App ID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  apid: &amp;quot;XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure SDK ==&lt;br /&gt;
There are two steps required for configuring the SDK:&lt;br /&gt;
*Add Static Queue Snippet&lt;br /&gt;
*Create SDK Instance&lt;br /&gt;
&lt;br /&gt;
=== Add Static Queue Snippet ===&lt;br /&gt;
Add the following script tag to the website:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
!function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.&lt;br /&gt;
&lt;br /&gt;
===Create SDK Instance===&lt;br /&gt;
To initialize the SDK, create an SDK instance by making the initialization API call:&lt;br /&gt;
&lt;br /&gt;
==== Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
NOLBUNDLE.nlsQ(&amp;quot;&amp;lt;apid&amp;gt;&amp;quot;, &amp;quot;&amp;lt;instanceName&amp;gt;&amp;quot;,{nol_sdkDebug: &amp;quot;debug&amp;quot;})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating an instance, pass the following  values:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter	!! Description	!! Required !! Values&lt;br /&gt;
|-&lt;br /&gt;
| apid	&lt;br /&gt;
|| Unique ID assigned to player/site. &lt;br /&gt;
*Test: begins with ‘T’ and is used for testing &lt;br /&gt;
*Production: begins with ‘P’ and is used in live environment when testing and certification is completed&lt;br /&gt;
||Yes||'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'&lt;br /&gt;
|-&lt;br /&gt;
|instanceName ||	Name of SDK instance ||Yes	 ||	&amp;quot;any string value&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_sdkDebug	|| Enables Nielsen console logging. Only required for testing	||Optional	|| nol_sdkDebug: &amp;quot;debug&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the initialization call is made, a unique static configuration file, &amp;lt;apid&amp;gt;.js, will be downloaded based on the apid and will be cached on the user’s browser.&lt;br /&gt;
&lt;br /&gt;
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”.&lt;br /&gt;
&lt;br /&gt;
==== Example SDK Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example SDK Configuration ===&lt;br /&gt;
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
  // Add Static Queue Snippet&lt;br /&gt;
 !function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Created SDK Instance&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;&amp;quot;true&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  isAudio:        'true',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata Object ====&lt;br /&gt;
The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type	|| type of ad	|| 'preroll', 'midroll', or 'postroll' ||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Ad Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create pre-roll ad object&lt;br /&gt;
var prerollMetadataObject = &lt;br /&gt;
{  &lt;br /&gt;
  assetid: 'AD-1',&lt;br /&gt;
  type:    'preroll'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
The method for calling events is ggPM().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
nSdkInstance.ggPM('event', parameter);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
The events are included in the table below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event name !! Values to pass !!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each content/ad metadata object&lt;br /&gt;
|-&lt;br /&gt;
| 'setPlayheadPosition'&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;AOD (or ad ): || current position in seconds (integer) &amp;lt;br/&amp;gt;&lt;br /&gt;
*&amp;quot;Live: current Unix timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position in seconds	|| Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| This event has to be called once for the current audio asset at the end of the playback.&lt;br /&gt;
At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Playhead position as integer&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' has to be called every second&lt;br /&gt;
&lt;br /&gt;
==== Example Events ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass ( Object ):''' Content Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', contentMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass  ( Object ):''' Pre-roll AD Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', prerollMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' setPlayheadPosition  |  '''Value Pass ( Integer ):''' playheadPosition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' stop  |  '''Value Pass ( Integer ):''' stopPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('stop', stopPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' end  |  '''Value Pass ( Integer ):''' endPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('end', endPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Interrupt Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== Pause Event ===&lt;br /&gt;
To indicate pause&lt;br /&gt;
&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending pings – [[loadMetadata]] and [[playheadPosition]] - once the playback resumes.&lt;br /&gt;
&lt;br /&gt;
=== Other Interrupt Scenarios ===&lt;br /&gt;
The following possible browser interruption scenarios must be handled:&lt;br /&gt;
&lt;br /&gt;
* Browser/Tab close&lt;br /&gt;
* Leaving the page to another destination&lt;br /&gt;
* Pressing the stop button&lt;br /&gt;
&lt;br /&gt;
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var stopped = false;&lt;br /&gt;
function closePlayer() {&lt;br /&gt;
	if (stopped) {return;}&lt;br /&gt;
	stopped = true;&lt;br /&gt;
	if (inMidroll) {    // Only inside a midroll indicate &amp;lt;stop&amp;gt; for the ad&lt;br /&gt;
		nSdkInstance.ggPM('stop', playheadPositionMidroll);&lt;br /&gt;
	}&lt;br /&gt;
	nSdkInstance.ggPM('end', playheadPositionContent);    // Indicate &amp;lt;end&amp;gt; for the content&lt;br /&gt;
};&lt;br /&gt;
window.addEventListener(&amp;quot;beforeunload&amp;quot;, function (e) {&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
window.addEventListener(&amp;quot;pagehide&amp;quot;, function (e) {	// for iOS mobile &amp;quot;pagehide&amp;quot; recommended by apple&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note:''' User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use &amp;quot;onpagehide&amp;quot; event as well).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  SDK Event Lifecycle ==&lt;br /&gt;
&lt;br /&gt;
The sample event lifecycle can be used as a reference for identifying the order for calling events.&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle without ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:even browser no ads.png]]&lt;br /&gt;
&lt;br /&gt;
==== Example without ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);  // must be called as start of stream&lt;br /&gt;
&lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playheads every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle with ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:event browser.png|event browser.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example with ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)&lt;br /&gt;
 &lt;br /&gt;
// PREROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end pre-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);&lt;br /&gt;
&lt;br /&gt;
// MIDROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
  &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end mid-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); &lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// POSTROLL&lt;br /&gt;
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.&lt;br /&gt;
&lt;br /&gt;
'''Note :''' For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll&lt;br /&gt;
&lt;br /&gt;
== Nielsen Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.&lt;br /&gt;
* A notice that the player includes proprietary measurement software that allows users to contribute to market research (such as Nielsen TV Ratings).&lt;br /&gt;
* A link to the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.&lt;br /&gt;
On the Nielsen Digital Measurement Privacy Policy page, users can click Choices to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen online measurement, click a link to receive an opt-out cookie.&lt;br /&gt;
&lt;br /&gt;
The following paragraph is a template for an opt-out statement.&lt;br /&gt;
&lt;br /&gt;
''The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen TV Ratings. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.''&lt;br /&gt;
&lt;br /&gt;
====Opt Back In====&lt;br /&gt;
&lt;br /&gt;
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'debug'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&lt;br /&gt;
====Example Production Initialization Call ====&lt;br /&gt;
Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;, &amp;quot;myPlayerName&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6448</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6448"/>
		<updated>2023-07-17T07:52:50Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Ad Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSONObject adMetadata = new JSONObject()&lt;br /&gt;
   .put(&amp;quot;assetid&amp;quot;, &amp;quot;unique_postroll_ad_id&amp;quot;)&lt;br /&gt;
   .put(&amp;quot;type&amp;quot;, &amp;quot;postroll&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6447</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6447"/>
		<updated>2023-07-17T07:52:37Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6446</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6446"/>
		<updated>2023-07-17T07:52:17Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6445</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6445"/>
		<updated>2023-07-17T07:51:52Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Create Metadata Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call for video measurement'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Ad Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSONObject adMetadata = new JSONObject()&lt;br /&gt;
   .put(&amp;quot;assetid&amp;quot;, &amp;quot;unique_postroll_ad_id&amp;quot;)&lt;br /&gt;
   .put(&amp;quot;type&amp;quot;, &amp;quot;postroll&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6444</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6444"/>
		<updated>2023-07-17T07:50:35Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6443</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6443"/>
		<updated>2023-07-17T07:50:00Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Audio Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6442</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6442"/>
		<updated>2023-07-17T07:48:54Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Audio Content Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6441</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6441"/>
		<updated>2023-07-17T07:47:57Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Audio Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6440</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6440"/>
		<updated>2023-07-17T07:46:21Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Create Metadata Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6439</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6439"/>
		<updated>2023-07-17T07:44:55Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6438</id>
		<title>DCR Italy AUDIO iOS SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_iOS_SDK&amp;diff=6438"/>
		<updated>2023-07-17T07:38:59Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Handling JSON Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[iOS SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for iOS using Xcode utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;If you are building an app for the 'kids category' please review the [[DCR_Italy_Video_iOS_SDK#Special_Note_Regarding_Apps_in_the_Kids_Category|Opt Out Requirement.]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi.Framework ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of CocoaPods. We recommend using the CocoaPods-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_iOS_Artifactory_Guide|Select to obtain CocoaPods implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
* [[DCR_Video_iOS_SDK_xcframework|Using the XCFramework bundle]]&lt;br /&gt;
&lt;br /&gt;
== Special Notes regarding iOS14 ==&lt;br /&gt;
=== Permission to Track === &lt;br /&gt;
&lt;br /&gt;
Apple recently released a new policy on consent requirements, that require the user's permission, to track them using their device's advertising identifier (IDFA).  To request the user's permission, use the AppTrackingTransparency framework. &lt;br /&gt;
&lt;br /&gt;
For more information, see:&lt;br /&gt;
* [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency]&lt;br /&gt;
* [https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/ Human Interface Guidelines]&lt;br /&gt;
* [https://developer.apple.com/documentation/adsupport AdSupport Framework]&lt;br /&gt;
&lt;br /&gt;
More detailed information on how the Nielsen SDK versions work with the AppTrackingTransparency framework is located on our [[ DCR Video iOS14 Migration|DCR Audio/Video iOS14 Migration]] page.&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
Prior to SDK Version 6.2.0.0 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 ([[iOS_Static_Framework_Setup|static framework]] is still available).&lt;br /&gt;
&lt;br /&gt;
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:&amp;lt;code&amp;gt; [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++] &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 [[DCR_Video_iOS_SDK#Removing_Simulators_.28Dynamic_Framework_Only.29|found below]].&lt;br /&gt;
&lt;br /&gt;
'''[[DCR_Video_iOS_SDK_xcframework|XCFramework]]''' is solution for the problems described above Apple recommends to use XCFrameworks. In XCFramework, we no longer build a single framework with multiple architectures. Instead, we build one small framework for each combination of architecture and target and store it in its own folder. The top-level XCFramework folder have folders like ios-arm64, ios-arm64-simulator, etc. Each of these folders is its own framework, complete with headers, modules, and binary.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Xcode Development Environment ===&lt;br /&gt;
Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.  In addition, when using the dynamic framework,  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&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': All communications between the SDK and the Census (Collection Facility) use HTTPS.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Special Note for Static Framework ===&lt;br /&gt;
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source codse.&lt;br /&gt;
If [[iOS_Static_Framework_Setup|static (xc)framework is integrated additional settings]] should be applied to fix build or runtime issues.&lt;br /&gt;
&lt;br /&gt;
=== Download Framework ===&lt;br /&gt;
The first step is to download and copy the [[Special:Downloads|NielsenAppApi.framework]] bundle to the app project directory. (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Framework ===&lt;br /&gt;
In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Add Path ===&lt;br /&gt;
Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.  (''Not required if using CocaPods'')&lt;br /&gt;
&lt;br /&gt;
=== Import Framework ===&lt;br /&gt;
Add NielsenAppApi.framework module in the source file of your app:&lt;br /&gt;
&lt;br /&gt;
==== Using Swift ====&lt;br /&gt;
Add the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Objective-C ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang =&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@import NielsenAppApi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== xCode 12 building errors ====&lt;br /&gt;
Developers who uses &amp;quot;fat&amp;quot; framework in their apps started reporting the following error that they get building the app in xCode 12.3+:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Building for iOS Simulator, but the linked and embedded framework 'MyFramework.framework' was built for iOS + iOS Simulator.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
The binary framework contains different code for the same architecture in multiple places, and Xcode doesn’t know how to handle it. There is workaround that people recommend to use in such cases:&lt;br /&gt;
* https://stackoverflow.com/questions/63267897/building-for-ios-simulator-but-the-linked-framework-framework-was-built&lt;br /&gt;
* https://stackoverflow.com/questions/63932158/xcode12-issus-ld-building-for-ios-simulator-but-linking-in-object-file-built&lt;br /&gt;
&lt;br /&gt;
==== IPA processing failure ====&lt;br /&gt;
&amp;lt;code&amp;gt;Assertion failed: Expected 4 archs in otool output:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error above is due to the &amp;quot;fat&amp;quot; (simulator+device) framework which will not appear if you have not enabled Bitcode.  To build your app with full Bitcode support, it is recommended that you use a [[DCR_Video_iOS_SDK_xcframework|XCFramework]] to avoid the 4 archs in otool output message.&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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. [[Dual_Instances_of_SDK|(Click here for an example of multiple instances)]]&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
&lt;br /&gt;
==== App tracking transparency framework ====&lt;br /&gt;
&lt;br /&gt;
To display the App Tracking Transparency authorization request for accessing the IDFA, update your &amp;lt;code&amp;gt;info.plist&amp;lt;/code&amp;gt; to add the &amp;lt;code&amp;gt;NSUserTrackingUsageDescription&amp;lt;/code&amp;gt; key with a custom message describing your usage. Below is an example description text:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;key&amp;gt;NSUserTrackingUsageDescription&amp;lt;/key&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;string&amp;gt;This identifier will be used to deliver personalized ads to you.&amp;lt;/string&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system automatically generates the prompt’s title, which includes the name of your app, then the usage description appears as part of the App Tracking&lt;br /&gt;
&lt;br /&gt;
To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please NOTE: It is important to initialize the NielsenSDK after the ATTrackingManager has Authorized usage.  When the SDK initializes, it checks the status of the ATTrackingManager.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an example in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section, folder name NielsenSampleVideoPlayer.&lt;br /&gt;
&lt;br /&gt;
====Swift 4.0 Example:====&lt;br /&gt;
&amp;lt;code&amp;gt;NielsenInit.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import Foundation&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class NielsenInit : NSObject {&lt;br /&gt;
    class func createNielsenApi(delegate: NielsenAppApiDelegate) -&amp;gt; NielsenAppApi?{&lt;br /&gt;
        &lt;br /&gt;
        let appInformation:[String: String] = [&lt;br /&gt;
            &amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
            &amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
            &amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
            &amp;quot;nol_devDebug&amp;quot;: &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
        ]       &lt;br /&gt;
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sample code using AVPlayer===&lt;br /&gt;
&amp;lt;code&amp;gt;ViewController.swift&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {&lt;br /&gt;
    &lt;br /&gt;
    let avPlayerViewController = AVPlayerViewController()&lt;br /&gt;
    var avPlayer:AVPlayer?&lt;br /&gt;
    var nielsenAppApi: NielsenAppApi!&lt;br /&gt;
&lt;br /&gt;
  override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
&lt;br /&gt;
self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)&lt;br /&gt;
NSLog(&amp;quot;Nielsen SDK initialized&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Objective C ==== &lt;br /&gt;
Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;    &lt;br /&gt;
#import &amp;quot;NlsAppApiFactory.h&amp;quot;&lt;br /&gt;
#import &amp;lt;NielsenAppApi/NielsenAppApi.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@implementation NlsAppApiFactory&lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    NSDictionary *appInformation = @{ &lt;br /&gt;
                                     @&amp;quot;appid&amp;quot;: &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appversion&amp;quot;: &amp;quot;1.0.2&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;appname&amp;quot;: &amp;quot;Nielsen Sample App&amp;quot;,&lt;br /&gt;
                                     @&amp;quot;nol_devDebug&amp;quot;: @&amp;quot;DEBUG&amp;quot;&lt;br /&gt;
                                    };&lt;br /&gt;
    &lt;br /&gt;
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following would be the &amp;lt;code&amp;gt;NlsAppApiFactory.h&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@class NielsenAppApi;&lt;br /&gt;
@protocol NielsenAppApiDelegate;&lt;br /&gt;
&lt;br /&gt;
@interface NlsAppApiFactory : NSObject &lt;br /&gt;
&lt;br /&gt;
+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id&amp;lt;NielsenAppApiDelegate&amp;gt;)delegate;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample Code: ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
@implementation ViewController&lt;br /&gt;
&lt;br /&gt;
- (void)viewDidLoad {&lt;br /&gt;
    [super viewDidLoad];&lt;br /&gt;
        &lt;br /&gt;
    //Getting the instance of Nielsen SDK&lt;br /&gt;
    nielsenApi = [NlsAppApiFactory createNielsenAppApiWithDelegate:nil];&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== Initializing the Nielsen AppSDK to measure the Viewability ==&lt;br /&gt;
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.&lt;br /&gt;
&lt;br /&gt;
=== Android ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||View ID of the UI element used as player view in application. getId() method of View class can be used to get this value.	||A positive integer used to identify the view. || 2131558561&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== iOS ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! #	!! Parameter Name	!! Description !! Supported Values !! Example&lt;br /&gt;
|-&lt;br /&gt;
| 1	|| containerId ||The tag of the UIView that represents the Player View	||The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. || &amp;quot;100&amp;quot; &amp;lt;br&amp;gt; &amp;quot;2131558561&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For iOS it is required to link additional frameworks that are needed for viewability engine:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;JavaScriptCore.framework&amp;lt;/code&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;WebKit.framework&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Nielsen AppSDK uses a tracking WebView (TWV) approach.  For more information on Viewability, please refer to [https://engineeringportal.nielsen.com/docs/Implementing_Viewability_with_AppSDK Implementing Viewability with AppSDK.]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for iOS, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
Example for Audio measurement:&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Swift = &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
let channelInfo = [&lt;br /&gt;
            &amp;quot;channelName&amp;quot;: &amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
];&lt;br /&gt;
        &lt;br /&gt;
let contentMetadata = [&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
            &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
            &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
            &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
            &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
            &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
            &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
            &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
            &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;     &lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
NSDictionary  *channelInfo = @&lt;br /&gt;
{&lt;br /&gt;
  @&amp;quot;channelName&amp;quot;:@&amp;quot;My Channel Name 1&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NSDictionary * contentMetadata = @ {&lt;br /&gt;
    @ &amp;quot;type&amp;quot;: @ &amp;quot;content&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isAudio&amp;quot;: @&amp;quot;true&amp;quot;,&lt;br /&gt;
    @ &amp;quot;assetid&amp;quot;: @ &amp;quot;88675545&amp;quot;,&lt;br /&gt;
    @ &amp;quot;title&amp;quot;: @ &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
    @ &amp;quot;isfullepisode&amp;quot;: @ &amp;quot;y&amp;quot;,  &lt;br /&gt;
    @ &amp;quot;program&amp;quot;: @ &amp;quot;Program Name&amp;quot;,&lt;br /&gt;
    @ &amp;quot;length&amp;quot;: @ &amp;quot;3600&amp;quot;,&lt;br /&gt;
    @ &amp;quot;airdate&amp;quot;: @ &amp;quot;20200321 10:05:00&amp;quot;,&lt;br /&gt;
    @ &amp;quot;adloadtype&amp;quot;: @ &amp;quot;2&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| ChannelInfo refers to the Channel name. This can be a free-form value&lt;br /&gt;
value such as a friendly name for the content being played. the SDK&amp;lt;br/&amp;gt;&lt;br /&gt;
will pass the application name automatically.&lt;br /&gt;
|| custom	|| No&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata ===&lt;br /&gt;
Configure metadata should remain constant throughout the completion of an episode or live stream&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName 	|| Any string representing the channel/stream || custom || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Content Metadata ===&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
NielsenInit.createMainBrandApi(delegate: self)&lt;br /&gt;
self.data = loadStaticMetadata()&lt;br /&gt;
self.nielsenMeter .loadMetadata(self.data)&amp;lt;/syntaxhighlight&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;nielsenMeter.play()&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nielsenMeter.loadMetadata(contentMetadata)&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;nielsenMeter.playheadPosition(pos);&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;nielsenMeter.end()&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;   [nielsenAppApi play:()];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenAppApi?.play();&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi loadMetadata:(contentMetadata)];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;self.nielsenAppApi?.loadMetadata(contentMetadata)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-(void) setPlayHeadPosition {&lt;br /&gt;
    &lt;br /&gt;
    //Setting play head position&lt;br /&gt;
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);&lt;br /&gt;
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){&lt;br /&gt;
        NSTimeInterval seconds = CMTimeGetSeconds(time);&lt;br /&gt;
        NSInteger intSec = seconds;&lt;br /&gt;
        &lt;br /&gt;
        //Sending data dictionary to SDK with updated playHead position.&lt;br /&gt;
        [nielsenApi playheadPosition:(intSec)];&lt;br /&gt;
    }];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
        //Monitor the Playhead position of the AVPlayer&lt;br /&gt;
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)&lt;br /&gt;
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -&amp;gt; Void in&lt;br /&gt;
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {&lt;br /&gt;
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;&lt;br /&gt;
                let pos = Int64(time);&lt;br /&gt;
                NSLog(&amp;quot;New Elapse Time = \(time)&amp;quot;);&lt;br /&gt;
                self.nielsenAppApi?.playheadPosition(pos);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== stop ===&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi stop];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
{{ExampleCode|&lt;br /&gt;
|Objective C = &amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;[nielsenApi end];&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|Swift = &amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;nielsenApi.end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by [https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html Apple:]&lt;br /&gt;
&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#OS-level_Opt-out|OS-level Opt-out]] - managed by AppTracking or Limit Ad Tracking setting on device (preferred approach).&lt;br /&gt;
*[[DCR_Italy_Video_iOS_SDK#User_Choice|User Choice]] - Direct call to SDK. Can be used without the Ad Framework&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the Kids Category ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
&lt;br /&gt;
Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version:] of the Nielsen SDK Framework. Also, you can use the [[Digital_Measurement_iOS_Artifactory_Guide|Artifactory method.]]&lt;br /&gt;
Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-outv&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen iOS&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.&lt;br /&gt;
&lt;br /&gt;
*If the User's device is running &amp;lt; iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.&lt;br /&gt;
*iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example ====&lt;br /&gt;
The below code is an example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
import UIKit&lt;br /&gt;
import WebKit&lt;br /&gt;
import NielsenAppApi&lt;br /&gt;
&lt;br /&gt;
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {&lt;br /&gt;
    var webView: WKWebView!&lt;br /&gt;
    var nielsenApi: NielsenAppApi!&lt;br /&gt;
    &lt;br /&gt;
    override func loadView() {&lt;br /&gt;
        webView = WKWebView()&lt;br /&gt;
        webView.navigationDelegate = self&lt;br /&gt;
        view = webView  }&lt;br /&gt;
    &lt;br /&gt;
    override func viewDidLoad() {&lt;br /&gt;
        super.viewDidLoad()&lt;br /&gt;
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: &amp;quot;new_ios_bg.png&amp;quot;)!) &lt;br /&gt;
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)  //create an instance &lt;br /&gt;
        &lt;br /&gt;
        if let appApi = self.nielsenApi {&lt;br /&gt;
            //Getting the optPut URL from SDK&lt;br /&gt;
            if let url = URL(string: appApi.optOutURL) { //query the nielsensdk for the current privacy page&lt;br /&gt;
                webView.load(URLRequest(url: url))&lt;br /&gt;
                webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
            }}}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework.]&lt;br /&gt;
&lt;br /&gt;
==== The User Choice opt-out method works as follows: ====&lt;br /&gt;
&lt;br /&gt;
*Get the Nielsen opt-out URL via [[optOutURL|optOutURL]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL|optOutURL]]&lt;br /&gt;
*Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
**Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
**Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
*Pass the detected URL to the [[userOptOut|userOptOut]] function&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;NielsenAppApi?.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;); // User opt-out &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Opt-out example code ====&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Apple released a policy update stating that the App Store will no longer accept updates for apps using the deprecated UIWebView (no specific date has been confirmed). Since then, we’ve recommended that you adopt WKWebView instead of UIWebView and WebView.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Objective-C =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;objective-c&amp;quot;&amp;gt;&lt;br /&gt;
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)&lt;br /&gt;
navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {&lt;br /&gt;
&lt;br /&gt;
    NSURLRequest *request = [navigationAction request];&lt;br /&gt;
    NSString *url = [[request URL]absoluteString];&lt;br /&gt;
    &lt;br /&gt;
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){&lt;br /&gt;
        [self.nielsenApi userOptOut:url];&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyAllow);&lt;br /&gt;
    }else{&lt;br /&gt;
        decisionHandler(WKNavigationActionPolicyCancel);&lt;br /&gt;
    }        &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Swift =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;swift&amp;quot;&amp;gt;&lt;br /&gt;
var webView: WKWebView!&lt;br /&gt;
var NIELSEN_URL_OPT_OUT : String = &amp;quot;nielsenappsdk://1&amp;quot;&lt;br /&gt;
var NIELSEN_URL_OPT_IN : String = &amp;quot;nielsenappsdk://0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, &lt;br /&gt;
decisionHandler: @escaping (WKNavigationActionPolicy) -&amp;gt; Void) {&lt;br /&gt;
&lt;br /&gt;
       let urlStr = navigationAction.request.url?.absoluteString&lt;br /&gt;
&lt;br /&gt;
        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){&lt;br /&gt;
            let appApi = self.nielsenApi&lt;br /&gt;
            appApi?.userOptOut(urlStr)&lt;br /&gt;
            decisionHandler(.allow)&lt;br /&gt;
&lt;br /&gt;
        }else{&lt;br /&gt;
           decisionHandler(.cancel)&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus|optOutStatus]] property in the Nielsen SDK API&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Removing Simulators (Dynamic Framework Only)==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='bash'&amp;gt;&lt;br /&gt;
&lt;br /&gt;
APP_PATH=&amp;quot;${TARGET_BUILD_DIR}/${WRAPPER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This script loops through the frameworks embedded in the application and&lt;br /&gt;
# removes unused architectures.&lt;br /&gt;
find &amp;quot;$APP_PATH&amp;quot; -name '*.framework' -type d | while read -r FRAMEWORK&lt;br /&gt;
do&lt;br /&gt;
FRAMEWORK_EXECUTABLE_NAME=$(defaults read &amp;quot;$FRAMEWORK/Info.plist&amp;quot; CFBundleExecutable)&lt;br /&gt;
FRAMEWORK_EXECUTABLE_PATH=&amp;quot;$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
echo &amp;quot;Executable is $FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
EXTRACTED_ARCHS=()&lt;br /&gt;
&lt;br /&gt;
for ARCH in $ARCHS&lt;br /&gt;
do&lt;br /&gt;
echo &amp;quot;Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME&amp;quot;&lt;br /&gt;
lipo -extract &amp;quot;$ARCH&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot; -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;&lt;br /&gt;
EXTRACTED_ARCHS+=(&amp;quot;$FRAMEWORK_EXECUTABLE_PATH-$ARCH&amp;quot;)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Merging extracted architectures: ${ARCHS}&amp;quot;&lt;br /&gt;
lipo -o &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; -create &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
rm &amp;quot;${EXTRACTED_ARCHS[@]}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Replacing original executable with thinned version&amp;quot;&lt;br /&gt;
rm &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
mv &amp;quot;$FRAMEWORK_EXECUTABLE_PATH-merged&amp;quot; &amp;quot;$FRAMEWORK_EXECUTABLE_PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
You can find some examples in the file [[Special:Downloads|Global iOS SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6437</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6437"/>
		<updated>2023-07-17T07:31:21Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Ad Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Ad Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSONObject adMetadata = new JSONObject()&lt;br /&gt;
   .put(&amp;quot;assetid&amp;quot;, &amp;quot;unique_postroll_ad_id&amp;quot;)&lt;br /&gt;
   .put(&amp;quot;type&amp;quot;, &amp;quot;postroll&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6436</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6436"/>
		<updated>2023-07-17T07:30:57Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Ad Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata ====&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSONObject adMetadata = new JSONObject()&lt;br /&gt;
   .put(&amp;quot;assetid&amp;quot;, &amp;quot;unique_postroll_ad_id&amp;quot;)&lt;br /&gt;
   .put(&amp;quot;type&amp;quot;, &amp;quot;postroll&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6435</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6435"/>
		<updated>2023-07-17T07:30:26Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Ad Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JSONObject adMetadata = new JSONObject()&lt;br /&gt;
   .put(&amp;quot;assetid&amp;quot;, &amp;quot;unique_postroll_ad_id&amp;quot;)&lt;br /&gt;
   .put(&amp;quot;type&amp;quot;, &amp;quot;postroll&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6434</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6434"/>
		<updated>2023-07-17T07:29:29Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Video Content Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6433</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6433"/>
		<updated>2023-07-17T07:28:57Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Audio Content Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6432</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6432"/>
		<updated>2023-07-17T07:26:04Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Video Content Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Video content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6431</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6431"/>
		<updated>2023-07-17T07:25:27Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6430</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6430"/>
		<updated>2023-07-17T07:24:15Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Audio Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6429</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6429"/>
		<updated>2023-07-17T07:21:54Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Audio Content Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6428</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6428"/>
		<updated>2023-07-17T07:21:21Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Audio Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6427</id>
		<title>DCR Italy AUDIO Browser SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6427"/>
		<updated>2023-07-17T07:19:42Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Example Ad Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings ([[DCR &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:&lt;br /&gt;
*Site launch events and how long page is viewed&lt;br /&gt;
*Time of viewing a sub section / page.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To get started, an App ID is needed. The App ID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  apid: &amp;quot;XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure SDK ==&lt;br /&gt;
There are two steps required for configuring the SDK:&lt;br /&gt;
*Add Static Queue Snippet&lt;br /&gt;
*Create SDK Instance&lt;br /&gt;
&lt;br /&gt;
=== Add Static Queue Snippet ===&lt;br /&gt;
Add the following script tag to the website:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
!function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.&lt;br /&gt;
&lt;br /&gt;
===Create SDK Instance===&lt;br /&gt;
To initialize the SDK, create an SDK instance by making the initialization API call:&lt;br /&gt;
&lt;br /&gt;
==== Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
NOLBUNDLE.nlsQ(&amp;quot;&amp;lt;apid&amp;gt;&amp;quot;, &amp;quot;&amp;lt;instanceName&amp;gt;&amp;quot;,{nol_sdkDebug: &amp;quot;debug&amp;quot;})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating an instance, pass the following  values:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter	!! Description	!! Required !! Values&lt;br /&gt;
|-&lt;br /&gt;
| apid	&lt;br /&gt;
|| Unique ID assigned to player/site. &lt;br /&gt;
*Test: begins with ‘T’ and is used for testing &lt;br /&gt;
*Production: begins with ‘P’ and is used in live environment when testing and certification is completed&lt;br /&gt;
||Yes||'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'&lt;br /&gt;
|-&lt;br /&gt;
|instanceName ||	Name of SDK instance ||Yes	 ||	&amp;quot;any string value&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_sdkDebug	|| Enables Nielsen console logging. Only required for testing	||Optional	|| nol_sdkDebug: &amp;quot;debug&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the initialization call is made, a unique static configuration file, &amp;lt;apid&amp;gt;.js, will be downloaded based on the apid and will be cached on the user’s browser.&lt;br /&gt;
&lt;br /&gt;
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”.&lt;br /&gt;
&lt;br /&gt;
==== Example SDK Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example SDK Configuration ===&lt;br /&gt;
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
  // Add Static Queue Snippet&lt;br /&gt;
 !function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Created SDK Instance&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;&amp;quot;true&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  isAudio:        'true',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata Object ====&lt;br /&gt;
The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type	|| type of ad	|| 'preroll', 'midroll', or 'postroll' ||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Ad Object =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create pre-roll ad object&lt;br /&gt;
var prerollMetadataObject = &lt;br /&gt;
{  &lt;br /&gt;
  assetid: 'AD-1',&lt;br /&gt;
  type:    'preroll'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
The method for calling events is ggPM().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
nSdkInstance.ggPM('event', parameter);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
The events are included in the table below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event name !! Values to pass !!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each content/ad metadata object&lt;br /&gt;
|-&lt;br /&gt;
| 'setPlayheadPosition'&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;AOD (or ad ): || current position in seconds (integer) &amp;lt;br/&amp;gt;&lt;br /&gt;
*&amp;quot;Live: current Unix timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position in seconds	|| Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| This event has to be called once for the current audio asset at the end of the playback.&lt;br /&gt;
At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Playhead position as integer&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' has to be called every second&lt;br /&gt;
&lt;br /&gt;
==== Example Events ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass ( Object ):''' Content Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', contentMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass  ( Object ):''' Pre-roll AD Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', prerollMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' setPlayheadPosition  |  '''Value Pass ( Integer ):''' playheadPosition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' stop  |  '''Value Pass ( Integer ):''' stopPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('stop', stopPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' end  |  '''Value Pass ( Integer ):''' endPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('end', endPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Interrupt Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== Pause Event ===&lt;br /&gt;
To indicate pause&lt;br /&gt;
&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending pings – [[loadMetadata]] and [[playheadPosition]] - once the playback resumes.&lt;br /&gt;
&lt;br /&gt;
=== Other Interrupt Scenarios ===&lt;br /&gt;
The following possible browser interruption scenarios must be handled:&lt;br /&gt;
&lt;br /&gt;
* Browser/Tab close&lt;br /&gt;
* Leaving the page to another destination&lt;br /&gt;
* Pressing the stop button&lt;br /&gt;
&lt;br /&gt;
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var stopped = false;&lt;br /&gt;
function closePlayer() {&lt;br /&gt;
	if (stopped) {return;}&lt;br /&gt;
	stopped = true;&lt;br /&gt;
	if (inMidroll) {    // Only inside a midroll indicate &amp;lt;stop&amp;gt; for the ad&lt;br /&gt;
		nSdkInstance.ggPM('stop', playheadPositionMidroll);&lt;br /&gt;
	}&lt;br /&gt;
	nSdkInstance.ggPM('end', playheadPositionContent);    // Indicate &amp;lt;end&amp;gt; for the content&lt;br /&gt;
};&lt;br /&gt;
window.addEventListener(&amp;quot;beforeunload&amp;quot;, function (e) {&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
window.addEventListener(&amp;quot;pagehide&amp;quot;, function (e) {	// for iOS mobile &amp;quot;pagehide&amp;quot; recommended by apple&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note:''' User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use &amp;quot;onpagehide&amp;quot; event as well).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  SDK Event Lifecycle ==&lt;br /&gt;
&lt;br /&gt;
The sample event lifecycle can be used as a reference for identifying the order for calling events.&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle without ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:even browser no ads.png]]&lt;br /&gt;
&lt;br /&gt;
==== Example without ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);  // must be called as start of stream&lt;br /&gt;
&lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playheads every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle with ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:event browser.png|event browser.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example with ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)&lt;br /&gt;
 &lt;br /&gt;
// PREROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end pre-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);&lt;br /&gt;
&lt;br /&gt;
// MIDROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
  &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end mid-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); &lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// POSTROLL&lt;br /&gt;
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.&lt;br /&gt;
&lt;br /&gt;
'''Note :''' For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll&lt;br /&gt;
&lt;br /&gt;
== Nielsen Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.&lt;br /&gt;
* A notice that the player includes proprietary measurement software that allows users to contribute to market research (such as Nielsen TV Ratings).&lt;br /&gt;
* A link to the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.&lt;br /&gt;
On the Nielsen Digital Measurement Privacy Policy page, users can click Choices to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen online measurement, click a link to receive an opt-out cookie.&lt;br /&gt;
&lt;br /&gt;
The following paragraph is a template for an opt-out statement.&lt;br /&gt;
&lt;br /&gt;
''The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen TV Ratings. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.''&lt;br /&gt;
&lt;br /&gt;
====Opt Back In====&lt;br /&gt;
&lt;br /&gt;
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'debug'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&lt;br /&gt;
====Example Production Initialization Call ====&lt;br /&gt;
Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;, &amp;quot;myPlayerName&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6426</id>
		<title>DCR Italy AUDIO Browser SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6426"/>
		<updated>2023-07-17T07:19:24Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Ad Metadata Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings ([[DCR &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:&lt;br /&gt;
*Site launch events and how long page is viewed&lt;br /&gt;
*Time of viewing a sub section / page.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To get started, an App ID is needed. The App ID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  apid: &amp;quot;XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure SDK ==&lt;br /&gt;
There are two steps required for configuring the SDK:&lt;br /&gt;
*Add Static Queue Snippet&lt;br /&gt;
*Create SDK Instance&lt;br /&gt;
&lt;br /&gt;
=== Add Static Queue Snippet ===&lt;br /&gt;
Add the following script tag to the website:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
!function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.&lt;br /&gt;
&lt;br /&gt;
===Create SDK Instance===&lt;br /&gt;
To initialize the SDK, create an SDK instance by making the initialization API call:&lt;br /&gt;
&lt;br /&gt;
==== Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
NOLBUNDLE.nlsQ(&amp;quot;&amp;lt;apid&amp;gt;&amp;quot;, &amp;quot;&amp;lt;instanceName&amp;gt;&amp;quot;,{nol_sdkDebug: &amp;quot;debug&amp;quot;})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating an instance, pass the following  values:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter	!! Description	!! Required !! Values&lt;br /&gt;
|-&lt;br /&gt;
| apid	&lt;br /&gt;
|| Unique ID assigned to player/site. &lt;br /&gt;
*Test: begins with ‘T’ and is used for testing &lt;br /&gt;
*Production: begins with ‘P’ and is used in live environment when testing and certification is completed&lt;br /&gt;
||Yes||'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'&lt;br /&gt;
|-&lt;br /&gt;
|instanceName ||	Name of SDK instance ||Yes	 ||	&amp;quot;any string value&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_sdkDebug	|| Enables Nielsen console logging. Only required for testing	||Optional	|| nol_sdkDebug: &amp;quot;debug&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the initialization call is made, a unique static configuration file, &amp;lt;apid&amp;gt;.js, will be downloaded based on the apid and will be cached on the user’s browser.&lt;br /&gt;
&lt;br /&gt;
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”.&lt;br /&gt;
&lt;br /&gt;
==== Example SDK Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example SDK Configuration ===&lt;br /&gt;
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
  // Add Static Queue Snippet&lt;br /&gt;
 !function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Created SDK Instance&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;&amp;quot;true&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  isAudio:        'true',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Ad Metadata Object ====&lt;br /&gt;
The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type	|| type of ad	|| 'preroll', 'midroll', or 'postroll' ||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create pre-roll ad object&lt;br /&gt;
var prerollMetadataObject = &lt;br /&gt;
{  &lt;br /&gt;
  assetid: 'AD-1',&lt;br /&gt;
  type:    'preroll'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
The method for calling events is ggPM().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
nSdkInstance.ggPM('event', parameter);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
The events are included in the table below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event name !! Values to pass !!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each content/ad metadata object&lt;br /&gt;
|-&lt;br /&gt;
| 'setPlayheadPosition'&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;AOD (or ad ): || current position in seconds (integer) &amp;lt;br/&amp;gt;&lt;br /&gt;
*&amp;quot;Live: current Unix timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position in seconds	|| Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| This event has to be called once for the current audio asset at the end of the playback.&lt;br /&gt;
At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Playhead position as integer&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' has to be called every second&lt;br /&gt;
&lt;br /&gt;
==== Example Events ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass ( Object ):''' Content Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', contentMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass  ( Object ):''' Pre-roll AD Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', prerollMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' setPlayheadPosition  |  '''Value Pass ( Integer ):''' playheadPosition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' stop  |  '''Value Pass ( Integer ):''' stopPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('stop', stopPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' end  |  '''Value Pass ( Integer ):''' endPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('end', endPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Interrupt Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== Pause Event ===&lt;br /&gt;
To indicate pause&lt;br /&gt;
&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending pings – [[loadMetadata]] and [[playheadPosition]] - once the playback resumes.&lt;br /&gt;
&lt;br /&gt;
=== Other Interrupt Scenarios ===&lt;br /&gt;
The following possible browser interruption scenarios must be handled:&lt;br /&gt;
&lt;br /&gt;
* Browser/Tab close&lt;br /&gt;
* Leaving the page to another destination&lt;br /&gt;
* Pressing the stop button&lt;br /&gt;
&lt;br /&gt;
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var stopped = false;&lt;br /&gt;
function closePlayer() {&lt;br /&gt;
	if (stopped) {return;}&lt;br /&gt;
	stopped = true;&lt;br /&gt;
	if (inMidroll) {    // Only inside a midroll indicate &amp;lt;stop&amp;gt; for the ad&lt;br /&gt;
		nSdkInstance.ggPM('stop', playheadPositionMidroll);&lt;br /&gt;
	}&lt;br /&gt;
	nSdkInstance.ggPM('end', playheadPositionContent);    // Indicate &amp;lt;end&amp;gt; for the content&lt;br /&gt;
};&lt;br /&gt;
window.addEventListener(&amp;quot;beforeunload&amp;quot;, function (e) {&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
window.addEventListener(&amp;quot;pagehide&amp;quot;, function (e) {	// for iOS mobile &amp;quot;pagehide&amp;quot; recommended by apple&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note:''' User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use &amp;quot;onpagehide&amp;quot; event as well).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  SDK Event Lifecycle ==&lt;br /&gt;
&lt;br /&gt;
The sample event lifecycle can be used as a reference for identifying the order for calling events.&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle without ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:even browser no ads.png]]&lt;br /&gt;
&lt;br /&gt;
==== Example without ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);  // must be called as start of stream&lt;br /&gt;
&lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playheads every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle with ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:event browser.png|event browser.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example with ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)&lt;br /&gt;
 &lt;br /&gt;
// PREROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end pre-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);&lt;br /&gt;
&lt;br /&gt;
// MIDROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
  &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end mid-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); &lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// POSTROLL&lt;br /&gt;
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.&lt;br /&gt;
&lt;br /&gt;
'''Note :''' For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll&lt;br /&gt;
&lt;br /&gt;
== Nielsen Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.&lt;br /&gt;
* A notice that the player includes proprietary measurement software that allows users to contribute to market research (such as Nielsen TV Ratings).&lt;br /&gt;
* A link to the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.&lt;br /&gt;
On the Nielsen Digital Measurement Privacy Policy page, users can click Choices to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen online measurement, click a link to receive an opt-out cookie.&lt;br /&gt;
&lt;br /&gt;
The following paragraph is a template for an opt-out statement.&lt;br /&gt;
&lt;br /&gt;
''The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen TV Ratings. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.''&lt;br /&gt;
&lt;br /&gt;
====Opt Back In====&lt;br /&gt;
&lt;br /&gt;
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'debug'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&lt;br /&gt;
====Example Production Initialization Call ====&lt;br /&gt;
Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;, &amp;quot;myPlayerName&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6425</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6425"/>
		<updated>2023-07-17T07:18:19Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Handling JSON Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Audio content Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6424</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6424"/>
		<updated>2023-07-17T07:12:12Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Create Metadata Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Create Metadata Objects ===&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6423</id>
		<title>DCR Italy AUDIO Android SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Android_SDK&amp;diff=6423"/>
		<updated>2023-07-17T07:11:36Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
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 &amp;amp; DTVR]]), and [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of an application like:&lt;br /&gt;
*Application launch events and how long app was running&lt;br /&gt;
*Time of viewing a page / sub section in the application.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
Before you start the integration, you will need:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 15%;&amp;quot; | Item&lt;br /&gt;
! Description&lt;br /&gt;
! Source&lt;br /&gt;
|-&lt;br /&gt;
 || '''App ID (appid)''' || Unique ID assigned to the player/site and configured by product. || Provided by Nielsen&lt;br /&gt;
|-&lt;br /&gt;
 || '''Nielsen SDK''' || Includes SDK frameworks and '''sample implementation'''; ''See [[Android SDK Release Notes]]'' || [[Special:Downloads|Download]]&lt;br /&gt;
|-&lt;br /&gt;
 || '''sfcode''' || Unique identifier for the environment that the SDK should point to || Provided by Nielsen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If need App ID(s) or our SDKs, feel free to reach out to us and we will be happy to help you get started.&lt;br /&gt;
Refer to [[Digital Measurement Onboarding]] guide for information on how to get a Nielsen App SDK and appid.&lt;br /&gt;
&lt;br /&gt;
=== Notes for WebView Contents ===&lt;br /&gt;
&amp;lt;code&amp;gt;Please note that if within your APP user can surf '''static contents''' recalled from your website the [[DCR_Italy_Static_Browser_SDK|browser static SDK]] have to inhibit from this pages.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Implementation ==&lt;br /&gt;
This guide covers implementation steps for Android Studio utilizing the Standard Nielsen SDK for DCR.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== How to obtain the NielsenAppApi ===&lt;br /&gt;
The Nielsen AppSDK can either be downloaded directly or can be integrated directly within an application through the use of Gradle. We recommend using the Gradle-based integration whenever possible to ensure you maintain the most recent changes and enhancements to the Nielsen libraries.&lt;br /&gt;
* [[Digital_Measurement_Android_Artifactory_Guide|Select to obtain Gradle implementation guide]]&lt;br /&gt;
* [[Special:Downloads|Select to Download Directly]]&lt;br /&gt;
&lt;br /&gt;
== Setting up your  Development Environment  ==&lt;br /&gt;
=== Configuring Android Development Environment ===&lt;br /&gt;
*The Nielsen App SDK (located in the [https://engineeringportal.nielsen.com/docs/Special:Downloads Downloads section] of the website) class is the primary application interface to the Nielsen App SDK on Android.&lt;br /&gt;
*The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.&lt;br /&gt;
*The Nielsen App SDK can also be added via [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Android_Artifactory_Guide Artifact Repository].&lt;br /&gt;
&lt;br /&gt;
'''Nielsen App SDK is compatible with Android OS versions 2.3+. Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.'''&lt;br /&gt;
&lt;br /&gt;
The requirement for the Java ''AppSdk.jar'' library and the ''libAppSdk.so'' native library will depend on the type of host application that will make use of them.&lt;br /&gt;
* '''For media player applications'''&lt;br /&gt;
** The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).&lt;br /&gt;
** If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.&lt;br /&gt;
&lt;br /&gt;
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select '''Add As Library'''.&lt;br /&gt;
Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.&lt;br /&gt;
* App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.&lt;br /&gt;
&lt;br /&gt;
==== Google Play Services ====&lt;br /&gt;
Add the Google Play Services in the project,&lt;br /&gt;
Steps: Android Studio -&amp;gt; File -&amp;gt; Project Structure -&amp;gt;(In module selection) select App -&amp;gt; Dependencies (tab) -&amp;gt; Click &amp;quot;+&amp;quot; button and search for &amp;lt;code&amp;gt;&amp;quot;*play-services*&amp;quot;&amp;lt;/code&amp;gt;.  Then select the most recent version of the play-services Artifact.&lt;br /&gt;
Ensure it is added in build.gradle (App level) file&lt;br /&gt;
&lt;br /&gt;
==== Google AD ID Permissions ====&lt;br /&gt;
The following is required if target API level is set to 31 (Android 12) with the Ad Version of the Nielsen SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;com.google.android.gms.permission.AD_ID&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manifest File ==== &lt;br /&gt;
* Add the following permissions on the project’s ''AndroidManifest.xml'' file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.ACCESS_NETWORK_STATE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name=&amp;quot;android.permission.INTERNET&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more details to handle runtime permissions in Android versions, please visit [https://developer.android.com/training/permissions/requesting.html].   &lt;br /&gt;
&lt;br /&gt;
* In &amp;lt;code&amp;gt;AndroidManifest.xml &amp;lt;/code&amp;gt;under &amp;lt;code&amp;gt;&amp;lt;application&amp;gt;&amp;lt;/code&amp;gt; add the following metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&amp;lt;meta-data &lt;br /&gt;
android:name=&amp;quot;com.google.android.gms.version&amp;quot; &lt;br /&gt;
android:value=&amp;quot;@integer/google_play_services_version&amp;quot;/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* App SDK checks to see if there is a Google service available and updated.&lt;br /&gt;
* If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.&lt;br /&gt;
&lt;br /&gt;
==== Library ====&lt;br /&gt;
Nielsen App SDK uses the following packages/classes from the Google Play service.&lt;br /&gt;
* google-play-services_lib&lt;br /&gt;
&lt;br /&gt;
==== Classes/package ====&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient;&lt;br /&gt;
* com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;&lt;br /&gt;
* com.google.android.gms.common.ConnectionResult;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesUtil;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesRepairableException;&lt;br /&gt;
* com.google.android.gms.common.GooglePlayServicesNotAvailableException;&lt;br /&gt;
&lt;br /&gt;
== SDK Initialization ==&lt;br /&gt;
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)&lt;br /&gt;
&lt;br /&gt;
The following table contains the list of arguments that can be passed via the AppInfo JSON schema.&lt;br /&gt;
*The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter / Argument !! Description !! Source !! Required? !! Example&lt;br /&gt;
|-&lt;br /&gt;
| appid || Unique Nielsen ID for the application. The ID is a GUID data type. If you did not receive your App ID, let us know and we will provide you. || Nielsen-specified || Yes || PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;br /&gt;
|-&lt;br /&gt;
| appname || Name of the application&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;Nielsen Sample App&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| appversion || Current version of the app used&lt;br /&gt;
|| Client-defined || Yes || &amp;quot;1.0.2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| sfcode || Nielsen collection facility to which the SDK should connect.&lt;br /&gt;
&lt;br /&gt;
|| Nielsen-specified || Yes || &lt;br /&gt;
|-&lt;br /&gt;
| nol_devDebug || Enables Nielsen console logging. Only required for testing&lt;br /&gt;
|| Nielsen-specified || Yes for Debugging / Testing App || &amp;quot;DEBUG&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debug flag for development environment ==&lt;br /&gt;
Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,&lt;br /&gt;
Pass the argument &amp;lt;code&amp;gt;@&amp;quot;nol_devDebug&amp;quot;:@&amp;quot;DEBUG&amp;quot;&amp;lt;/code&amp;gt;, in the JSON string . The permitted values are:&lt;br /&gt;
&lt;br /&gt;
* '''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.&lt;br /&gt;
* '''WARN''': Indicates potential integration / configuration errors or SDK issues.&lt;br /&gt;
* '''ERROR''': Indicates important integration errors or non-recoverable SDK issues.&lt;br /&gt;
* '''DEBUG''': Debug logs, used by the developers to debug more complex issues.&lt;br /&gt;
&lt;br /&gt;
Once the flag is active, it logs each API call made and the data passed. The log created by this flag is minimal.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note''': Activate the Debug flag in a Test environment.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sample SDK Initialization Code ===&lt;br /&gt;
[[AppSDK()|AppSDK()]] is no longer a singleton object and should be initialized as below.&lt;br /&gt;
====Initialization of App SDK object through a JSON object====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
  // Prepare AppSdk configuration object (JSONObject)&lt;br /&gt;
  JSONObject appSdkConfig = new JSONObject()&lt;br /&gt;
          .put(&amp;quot;appid&amp;quot;, &amp;quot;PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appversion&amp;quot;, &amp;quot;1.0.2&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;appname&amp;quot;, &amp;quot;Nielsen Sample App&amp;quot;)&lt;br /&gt;
          .put(&amp;quot;nol_devDebug&amp;quot;, &amp;quot;DEBUG&amp;quot;); // only for debug builds&lt;br /&gt;
&lt;br /&gt;
// Pass appSdkConfig to the AppSdk constructor&lt;br /&gt;
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);&lt;br /&gt;
}&lt;br /&gt;
catch (JSONException e)&lt;br /&gt;
{&lt;br /&gt;
  Log.e(TAG, &amp;quot;Couldn’t prepare JSONObject for appSdkConfig&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here, &amp;lt;code&amp;gt;appContext&amp;lt;/code&amp;gt; is the App context object and &amp;lt;code&amp;gt;appSdkConfig&amp;lt;/code&amp;gt; is JSON object for holding the parameters (&amp;lt;code&amp;gt;appid&amp;lt;/code&amp;gt;) the App passes to the Nielsen App SDK via a JSON string. The appid is obtained from Nielsen operational support and is unique to the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The integration of Nielsen App SDK will depend on type of client app.&lt;br /&gt;
*Ensure that SDK files (AppSdk.jar and libAppSdk.so [App SDK 1.2 Only]) are included under the App’s project and the App SDK is linked to the App (the setting to link App SDK to the App can be found on property page of the App’s project).&lt;br /&gt;
&lt;br /&gt;
== APP SDK Error &amp;amp; Event Codes ==&lt;br /&gt;
To view the Error and Event codes for Android, please review the [[APP SDK Event Codes|App SDK Event Code]] Reference page.&lt;br /&gt;
&lt;br /&gt;
== Configure Metadata ==&lt;br /&gt;
=== Handling JSON Metadata ===&lt;br /&gt;
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.&lt;br /&gt;
* NSDictionary object&lt;br /&gt;
** If an object of unexpected type is passed to the method, the error message will be logged.&lt;br /&gt;
** If string has invalid JSON format, the error message will be logged.&lt;br /&gt;
* JSON value must be string value.&lt;br /&gt;
** This includes boolean and numeric values. For example, a value of true should be represented with &amp;quot;true&amp;quot;, number value 123 should be &amp;quot;123&amp;quot;.&lt;br /&gt;
** All the Nielsen Key names (e.g. appid, program) are case-sensitive. Use the correct variable name as specified in the documentation.&lt;br /&gt;
* JSON string can be prepared using either raw NSString or serialized NSDictionary.&lt;br /&gt;
&lt;br /&gt;
==== Java ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
JSONObject channelInfo = new JSONObject()&lt;br /&gt;
    .put(&amp;quot;channelname&amp;quot;,&amp;quot;My Channel Name 1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
JSONObject contentMetadata = new JSONObject()&lt;br /&gt;
//SDK Metadata&lt;br /&gt;
    .put(&amp;quot;type&amp;quot;, &amp;quot;content&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isAudio&amp;quot;, &amp;quot;true&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;assetid&amp;quot;, &amp;quot;vid345-67483&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;program&amp;quot;, &amp;quot;Program Name&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;title&amp;quot;, &amp;quot;Program S3, EP1&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;length&amp;quot;, &amp;quot;3600&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;isfullepisode&amp;quot;, &amp;quot;y&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;adloadtype&amp;quot;, &amp;quot;2&amp;quot;)&lt;br /&gt;
    .put(&amp;quot;airdate&amp;quot;, &amp;quot;20161013 20:00:00&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure metadata === &lt;br /&gt;
channelName should remain constant throughout the completion of an episode or live stream.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| channelName	|| Any string representing the channel/stream&lt;br /&gt;
|| custom	|| Yes&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of asset || &amp;lt;code&amp;gt;'content'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;'true'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid || unique ID assigned to asset (32 Character limit) || custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|-&lt;br /&gt;
| program || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| title || name of program (100 character limit) || custom || Yes&lt;br /&gt;
|-&lt;br /&gt;
| length || length of content in seconds || Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| airdate || The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; || YYYYMMDD HH24:MI:SS&lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| Yes&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode || full episode flag || &amp;lt;code&amp;gt;'y'&amp;lt;/code&amp;gt;- full episode, &amp;lt;code&amp;gt;'n'&amp;lt;/code&amp;gt;- non full episode || Yes&lt;br /&gt;
|-&lt;br /&gt;
| adloadtype || type of ad load:&lt;br /&gt;
*&amp;lt;code&amp;gt;'1'&amp;lt;/code&amp;gt; Linear – matches TV ad load&lt;br /&gt;
*&amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
|| &amp;lt;code&amp;gt;'2'&amp;lt;/code&amp;gt; - DCR measures content with dynamic ads &lt;br /&gt;
|| Yes&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata ===&lt;br /&gt;
The Ad Metadata (if applicable) should be passed for each individual ad.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type 	|| type of Ad	||  &amp;lt;code&amp;gt;'preroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'midroll'&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;'postroll'&amp;lt;/code&amp;gt; || Yes&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to Ad	|| custom (no [[Special Characters|Special Characters]]) || Yes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example Ad Object ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// create Ad object&lt;br /&gt;
&amp;quot;ad&amp;quot;: {&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;AD-ID123&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure API Calls ==&lt;br /&gt;
&amp;lt;!--[[File:appsdkTimeline-DCR.png|icon|link=]]--&amp;gt;&lt;br /&gt;
=== Sample API Sequence ===&lt;br /&gt;
A Sample API sequence could follow this flow:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
|On App Start||&amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadata]; &amp;lt;/code&amp;gt; || // Pass Static Metadata here if applicable&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;[nielsenMeter play];&amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;[nielsenMeter loadMetadata: contentMetadataObject];&amp;lt;/code&amp;gt; || // MetadataObject contains the JSON metadata&amp;lt;br&amp;gt; for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;[nielsenMeter setplayheadPosition: position];&amp;lt;/code&amp;gt; || // playheadPosition is position of the playhead &amp;lt;br&amp;gt;while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;[nielsenMeter end];&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== SDK Events ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event !!	Parameter	!! Description&lt;br /&gt;
|-&lt;br /&gt;
| 'play'	|| 	|| Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each asset&lt;br /&gt;
|-&lt;br /&gt;
| 'playheadPosition'	|| playhead position as integer&amp;lt;br/&amp;gt;&lt;br /&gt;
AOD: current position in seconds &amp;lt;br/&amp;gt;&lt;br /&gt;
Live: current UNIX timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
Note: 'PlayheadPosition' has to be called every second&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position	|| Call during any interruption to content or Ad playback and at the end of each Ad.&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| Call when the current audio asset completes playback and pass the playhead position. &amp;lt;br/&amp;gt;&lt;br /&gt;
Example: At the end of the content stream, if the user switches to another piece of content, when the media player is reloaded or closed.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: For livestream, send the UNIX timestamp, for AOD send the time in seconds as integer. The final playhead position must be sent for the current asset being played before calling &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; or&amp;lt;code&amp;gt; '''loadmetadata'''&amp;lt;/code&amp;gt;,.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Life cycle of SDK instance ===&lt;br /&gt;
Life cycle of SDK instance includes four general states:&lt;br /&gt;
# '''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 '''Idle state'''.&lt;br /&gt;
# '''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 an event to occur.&lt;br /&gt;
# '''Processing state''' – The SDK instance is processing playing information. The &amp;lt;code&amp;gt;'''play'''&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.&lt;br /&gt;
## &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; – Call this API every one second when playhead position is active.  If a LIVE event, use the current UNIX timestamp (seconds since Jan-1-1970 UTC).&lt;br /&gt;
## &amp;lt;code&amp;gt;'''stop'''&amp;lt;/code&amp;gt; – Call this API when the content or Ad playback is interrupted and at the end of each Ad. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''end'''&amp;lt;/code&amp;gt; – Call when content completes. When called, the SDK instance exits from Processing state.&lt;br /&gt;
# '''Disabled state''' – The SDK instance is disabled and is not processing playing information. &lt;br /&gt;
## &amp;lt;code&amp;gt;'''appDisableApi'''&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''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.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
* As soon as the playback resumes, call &amp;lt;code&amp;gt;'''loadMetadata''' &amp;lt;/code&amp;gt; and   &amp;lt;code&amp;gt;'''playheadPosition'''&amp;lt;/code&amp;gt; &amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== API Call Sequence ===&lt;br /&gt;
==== Use Case 1: Content has no Advertisements ====&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for content as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;type&amp;quot;: &amp;quot;content&amp;quot;,&lt;br /&gt;
  &amp;quot;isAudio&amp;quot;: &amp;quot;true&amp;quot;,&lt;br /&gt;
  &amp;quot;assetid&amp;quot;: &amp;quot;88675545&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Program S3, EP1&amp;quot;,&lt;br /&gt;
  &amp;quot;isfullepisode&amp;quot;:&amp;quot;y&amp;quot;,&lt;br /&gt;
  &amp;quot;adloadtype&amp;quot;:&amp;quot;2&amp;quot;,&lt;br /&gt;
  &amp;quot;program&amp;quot;:&amp;quot;Program Name&amp;quot;,&lt;br /&gt;
  &amp;quot;length&amp;quot;:&amp;quot;3600&amp;quot;, &lt;br /&gt;
  &amp;quot;airdate&amp;quot;:&amp;quot;20171020 10:05:00&amp;quot;   &lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] every one second until a pause / stop.&lt;br /&gt;
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // Call at start of each new stream&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| Content || &amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| Interruption || &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // call stop when content playback is interrupted&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Resume Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt;  || // Call loadMetadata and pass content metadata object when content resumes&lt;br /&gt;
|- &lt;br /&gt;
|&amp;lt;code&amp;gt;mAppSdk.setPlayheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // continue pasing playhead position every second starting from position where content is resumed&lt;br /&gt;
|- &lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Content playback is completed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Use Case 2: Content has Advertisements ====&lt;br /&gt;
&lt;br /&gt;
Call [[play()]] at start of stream&lt;br /&gt;
&lt;br /&gt;
Call [[loadMetadata()]] with JSON metadata for ad as below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;{&lt;br /&gt;
   &amp;quot;type&amp;quot;: &amp;quot;preroll&amp;quot;,&lt;br /&gt;
   &amp;quot;assetid&amp;quot;: &amp;quot;ad123&amp;quot;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata]] and playhead position through [[playheadPosition]].&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Call [[playheadPosition|playheadPosition()]] 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()]].&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type !! Sample code !! Description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Start of stream || &amp;lt;code&amp;gt;mAppSdk.play(); &amp;lt;/code&amp;gt; || // stream starts&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Preroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(prerollMetadataObject);&amp;lt;/code&amp;gt; || // prerollMetadataObject contains the JSON metadata for the preroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the preroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after preroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Midroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(midrollMetaDataObject);&amp;lt;/code&amp;gt; || // midrollMetadataObject contains the JSON metadata for the midroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the midroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after midroll occurs&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | Content Resumes || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(contentMetaDataObject);&amp;lt;/code&amp;gt; || // contentMetadataObject contains the JSON metadata for the content being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the content is being played&lt;br /&gt;
|-&lt;br /&gt;
| End of Stream || &amp;lt;code&amp;gt;mAppSdk.end();&amp;lt;/code&amp;gt; || // Call end() at the end of content&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; | Postroll || &amp;lt;code&amp;gt;mAppSdk.loadMetadata(postrollMetaDataObject);&amp;lt;/code&amp;gt; || // postrollMetadataObject contains the JSON metadata for the postroll ad&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.playheadPosition(playheadPosition);&amp;lt;/code&amp;gt; || // position is position of the playhead while the postroll ad is being played&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mAppSdk.stop();&amp;lt;/code&amp;gt; || // Call stop after postroll occurs&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Note: Each Ad playhead should 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.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sequence of Calls ==&lt;br /&gt;
=== play ===&lt;br /&gt;
Call &amp;lt;code&amp;gt;play&amp;lt;/code&amp;gt; at the start of each new stream. If changing audio or listening to a new audio, call &amp;lt;code&amp;gt;play()&amp;lt;/code&amp;gt; each time. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void play(JSONObject channelInfo);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== loadMetadata ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void loadMetadata(JSONObject contentMetadata);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== playheadPosition ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void setPlayheadPosition(long position);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== stop ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void stop()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== end ===&lt;br /&gt;
When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public void end()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling Foreground and Background states ==&lt;br /&gt;
There are a few approaches to managing the Foreground and Background states of an app available to use for state measurement.&lt;br /&gt;
&lt;br /&gt;
*Utilizing the Androidx LifeCycleObserver (The recommended approach starting sdk version 7.1.0.0+)&lt;br /&gt;
*Utilizing the SdkBgFgDetectionUtility class&lt;br /&gt;
*Adding a tag to the Manifest XML&lt;br /&gt;
*Manual Management&lt;br /&gt;
=== The LifeCycleObserver ===&lt;br /&gt;
AndroidX replaces the original support library APIs with packages in the androidx namespace, and Android Studio 3.2 and higher provides an automated migration tool. (Select '''Refactor&amp;gt; Migrate to AndroidX''' from the menu bar.)&lt;br /&gt;
&lt;br /&gt;
Starting with version 7.1.0, with AndroidX support, an additional utility is provided in the AppSDK - application background/foreground state detection by the AppSdk leveraging the Android Architecture component &amp;quot;LifeCycleObserver&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The AppSdk is now capable of detecting the application UI visibility state transitions between background and foreground, without forcing the applications to register for AppSdk's AppSdkApplication class, which is responsible for handling the detection of application background/foreground state transitions at present.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Please note, that if you already have an app designed that utilizes the depreciated SdkBgFgDetectionUtility Class, the AppSDK will ignore any calls to these methods if it can utilize the LifeCycleObserver. LifeCycleObserver based auto detection will take precedence.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding the AndroidX dependency ====&lt;br /&gt;
In order to make use of the app background/foreground state transition auto detection feature of AndroidX AppSdk, the app gradle file needs the androidx dependency. The AppSdk API calls - &amp;lt;code&amp;gt;appInForeground()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;appInBackground()&amp;lt;/code&amp;gt; will still be respected by AppSdk by executing the old AppSdk flow of handling &amp;quot;app in foreground&amp;quot; and &amp;quot;app in background&amp;quot; states as is.&lt;br /&gt;
&lt;br /&gt;
==== Using the LifeCycle Extension ====&lt;br /&gt;
The following androidx dependency is required in the app gradle file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;implementation &amp;quot;androidx.lifecycle:lifecycle-extensions:2.1.0&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If you would like to take advantage of this auto detection feature of AppSdk at the very initial stage (e.g. splash screen or at of app launch time), before the AppSdk is initialized, can do so by calling the following newly introduced AppSdk public api, passing the application context :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;public static void registerLifeCycleObserver(Context applicationContext)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Log messages for the new auto detection ====&lt;br /&gt;
&lt;br /&gt;
*When the AppSdk app successfully registers for the LifeCycleObserver : &amp;lt;code&amp;gt;Registered LifeCycleObserver for App Background/Foreground auto-detection&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the foreground state :&amp;lt;code&amp;gt;App is in foreground, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the app enters the background state :&amp;lt;code&amp;gt;App is in background, auto detected by AppSDK&amp;lt;/code&amp;gt;&lt;br /&gt;
*If the client app doesn't have the &amp;quot;androidx&amp;quot; gradle dependency and AppSdk fails to register LifeCycleObserver :&amp;lt;code&amp;gt;AndroidX LifecycleObserver can not be observed. Please use androidx dependency to activate SDK auto-detection of app background/foreground state.&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInForeground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - foreground&amp;lt;/code&amp;gt;&lt;br /&gt;
*When the appInBackground() is explicitly called while LifeCycleObserver auto detection is active :&amp;lt;code&amp;gt;Ignoring the appInBackground() call, as the App Background/Foreground auto-detection is active. The current state is - background&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The SdkBgFgDetectionUtility class ===&lt;br /&gt;
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes&lt;br /&gt;
&lt;br /&gt;
*Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.&lt;br /&gt;
*Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.&lt;br /&gt;
*Custom implementation of the required methods within your application.&lt;br /&gt;
&lt;br /&gt;
==== ForeGround/Background Measurement via AndroidManifest ====&lt;br /&gt;
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt; &amp;lt;application android:name=&amp;quot;com.nielsen.app.sdk.AppSdkApplication&amp;quot;&amp;gt; &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using the Android SdkBgFbDetectionUtility Class ====&lt;br /&gt;
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the [[Android Background Foreground|SdkBgFgDetectionUtility class.]] The [[Android Background Foreground|SdkBgFgDetectionUtility class.]] is compatible with Android 4+ and has been made available to Nielsen clients. (You will need to copy/paste the code provided into a file).&lt;br /&gt;
&lt;br /&gt;
==== Manual Background/ForeGround State Management ====&lt;br /&gt;
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided [[Android Background Foreground|SdkBgFgDetectionUtility class.]] the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.&lt;br /&gt;
&lt;br /&gt;
The SDK is informed about app state using the below methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInForeground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;AppLaunchMeasurementManager.appInBackground(getApplicationContext());&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).&lt;br /&gt;
&lt;br /&gt;
== Interruptions during playback ==&lt;br /&gt;
As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:&lt;br /&gt;
* Pause / Play&lt;br /&gt;
* Network Loss (Wi-Fi / Airplane / Cellular)&lt;br /&gt;
* Call Interrupt (SIM or Third party Skype / Hangout call)&lt;br /&gt;
* Alarm Interrupt&lt;br /&gt;
* Content Buffering&lt;br /&gt;
* Device Lock / Unlock &lt;br /&gt;
* App going in the Background/Foreground &lt;br /&gt;
* Channel / Station Change Scenario&lt;br /&gt;
* Unplugging of headphone&lt;br /&gt;
In case of encountering one of the above interruptions, the player application needs to&lt;br /&gt;
* Call [[stop]] immediately (except when content is buffering) and withhold sending playhead position.&lt;br /&gt;
* Start sending API calls – &amp;lt;code&amp;gt;'loadMetadata'&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;'playheadPosition'&amp;lt;/code&amp;gt; for the new viewing session, once the playback resumes.&lt;br /&gt;
Please see the [https://engineeringportal.nielsen.com/docs/Digital_Measurement_Interruption_Scenarios Interruption Scenarios Page] for more details&lt;br /&gt;
&lt;br /&gt;
== Privacy and Opt-Out ==&lt;br /&gt;
There are two primary methods for implementing user Opt-out preferences:&lt;br /&gt;
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').&lt;br /&gt;
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.&lt;br /&gt;
&lt;br /&gt;
=== Special Note Regarding Apps in the '''Kids Category''' ===&lt;br /&gt;
If you are building an app that will be listed in the Kids Category:&lt;br /&gt;
#  Ensure that you are using the NoID version of the Nielsen SDK Framework.&lt;br /&gt;
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OS-level Opt-out ===&lt;br /&gt;
''OS-level Opt-out'' method available on Nielsen Android.&lt;br /&gt;
&lt;br /&gt;
The Nielsen SDK automatically leverages the Android's ''Opt out of Ads Personalization'' setting. The user is opted out of demographic measurement if the OS-level ''&amp;quot;Opt out of Ads Personalization&amp;quot;'' setting is ''enabled''. As a publisher, you cannot override this setting.&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Nielsen opt-out URL ====&lt;br /&gt;
&lt;br /&gt;
*Get the current Nielsen opt-out URL via [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
*Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()|userOptOutURLString()]]&lt;br /&gt;
&lt;br /&gt;
==== Webview Example  ====&lt;br /&gt;
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {&lt;br /&gt;
&lt;br /&gt;
    WebView webView;&lt;br /&gt;
    AppSdk appSdk;&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(@Nullable Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_optout);&lt;br /&gt;
        webView = (WebView) findViewById(R.id.webView);&lt;br /&gt;
&lt;br /&gt;
        webView.getSettings().setJavaScriptEnabled(true);&lt;br /&gt;
&lt;br /&gt;
        webView.setWebViewClient(new WebViewClient() {&lt;br /&gt;
            @SuppressWarnings(&amp;quot;deprecation&amp;quot;)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {&lt;br /&gt;
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();&lt;br /&gt;
            }&lt;br /&gt;
            @TargetApi(android.os.Build.VERSION_CODES.M)&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {&lt;br /&gt;
                // Redirect to deprecated method, so you can use it in all SDK versions&lt;br /&gt;
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        NielsenInit nielsenInit = new NielsenInit();       // Initializing the NielsenSDK&lt;br /&gt;
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance&lt;br /&gt;
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK&lt;br /&gt;
        webView.loadUrl(url);                         //Display to the user in a Webview&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User Choice ===&lt;br /&gt;
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.&lt;br /&gt;
&lt;br /&gt;
Nielsen Android SDK 5.1.1.18 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.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== The legacy opt-out method works as follows: ====&lt;br /&gt;
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]&lt;br /&gt;
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]&lt;br /&gt;
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView&lt;br /&gt;
** Opt-out if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://1&amp;lt;/code&amp;gt;&lt;br /&gt;
** Opt-in if the WebView URL = &amp;lt;code&amp;gt;nielsenappsdk://0&amp;lt;/code&amp;gt;&lt;br /&gt;
* Pass the detected URL to the [[userOptOut()]] function&lt;br /&gt;
** Example: &amp;lt;syntaxhighlight lang=java&amp;gt;appSdk.userOptOut(&amp;quot;nielsenappsdk://1&amp;quot;);  // User opt-out&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Legacy Opt Out example code ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
private class MonitorWebView extends WebViewClient&lt;br /&gt;
{&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_OUT = &amp;quot;nielsenappsdk://1&amp;quot;;&lt;br /&gt;
  private static final String NIELSEN_URL_OPT_IN = &amp;quot;nielsenappsdk://0&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean shouldOverrideUrlLoading(WebView view, String url)&lt;br /&gt;
  {&lt;br /&gt;
    if (NIELSEN_URL_OPT_OUT.equals(url)&lt;br /&gt;
      || NIELSEN_URL_OPT_IN.equals(url))&lt;br /&gt;
    {&lt;br /&gt;
      // Get AppSdk instance from the host&lt;br /&gt;
      AppSdk appSdk = HostApp.getAppSdk();&lt;br /&gt;
      // Send the URL to the AppSdk instance&lt;br /&gt;
      appSdk.userOptOut(url);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retrieve current Opt-Out preference ===&lt;br /&gt;
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 [[getOptOutStatus()]] property in the Nielsen Android SDK API,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Required Privacy Links ====&lt;br /&gt;
Users must either have access to the &amp;quot;About Nielsen Measurement&amp;quot; page, or have similar text available within the native app. Include &amp;quot;About Nielsen Measurement&amp;quot; and &amp;quot;Your Choices&amp;quot; link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.&lt;br /&gt;
&lt;br /&gt;
In addition, the following text must be included in your app store description.&lt;br /&gt;
&lt;br /&gt;
Si prega di notare che questa app include il software di misurazione proprietario di Nielsen che contribuisce alla ricerca di mercato. Per ulteriori informazioni, si prega di consultare il seguente link [https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it]&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, you will need to:&lt;br /&gt;
&lt;br /&gt;
# '''Disable Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_devDebug: 'DEBUG'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.&lt;br /&gt;
&lt;br /&gt;
== Sample Applications ==&lt;br /&gt;
&lt;br /&gt;
*You can find some examples in the file [[Special:Downloads|Global Android SDK Download]] from the '''SDK Downloads''' section&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6422</id>
		<title>DCR Italy AUDIO Browser SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6422"/>
		<updated>2023-07-17T07:06:45Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings ([[DCR &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:&lt;br /&gt;
*Site launch events and how long page is viewed&lt;br /&gt;
*Time of viewing a sub section / page.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To get started, an App ID is needed. The App ID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  apid: &amp;quot;XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure SDK ==&lt;br /&gt;
There are two steps required for configuring the SDK:&lt;br /&gt;
*Add Static Queue Snippet&lt;br /&gt;
*Create SDK Instance&lt;br /&gt;
&lt;br /&gt;
=== Add Static Queue Snippet ===&lt;br /&gt;
Add the following script tag to the website:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
!function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.&lt;br /&gt;
&lt;br /&gt;
===Create SDK Instance===&lt;br /&gt;
To initialize the SDK, create an SDK instance by making the initialization API call:&lt;br /&gt;
&lt;br /&gt;
==== Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
NOLBUNDLE.nlsQ(&amp;quot;&amp;lt;apid&amp;gt;&amp;quot;, &amp;quot;&amp;lt;instanceName&amp;gt;&amp;quot;,{nol_sdkDebug: &amp;quot;debug&amp;quot;})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating an instance, pass the following  values:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter	!! Description	!! Required !! Values&lt;br /&gt;
|-&lt;br /&gt;
| apid	&lt;br /&gt;
|| Unique ID assigned to player/site. &lt;br /&gt;
*Test: begins with ‘T’ and is used for testing &lt;br /&gt;
*Production: begins with ‘P’ and is used in live environment when testing and certification is completed&lt;br /&gt;
||Yes||'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'&lt;br /&gt;
|-&lt;br /&gt;
|instanceName ||	Name of SDK instance ||Yes	 ||	&amp;quot;any string value&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_sdkDebug	|| Enables Nielsen console logging. Only required for testing	||Optional	|| nol_sdkDebug: &amp;quot;debug&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the initialization call is made, a unique static configuration file, &amp;lt;apid&amp;gt;.js, will be downloaded based on the apid and will be cached on the user’s browser.&lt;br /&gt;
&lt;br /&gt;
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”.&lt;br /&gt;
&lt;br /&gt;
==== Example SDK Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example SDK Configuration ===&lt;br /&gt;
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
  // Add Static Queue Snippet&lt;br /&gt;
 !function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Created SDK Instance&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;&amp;quot;true&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  isAudio:        'true',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
&lt;br /&gt;
'''Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata Object ===&lt;br /&gt;
The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type	|| type of ad	|| 'preroll', 'midroll', or 'postroll' ||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create pre-roll ad object&lt;br /&gt;
var prerollMetadataObject = &lt;br /&gt;
{  &lt;br /&gt;
  assetid: 'AD-1',&lt;br /&gt;
  type:    'preroll'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
The method for calling events is ggPM().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
nSdkInstance.ggPM('event', parameter);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
The events are included in the table below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event name !! Values to pass !!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each content/ad metadata object&lt;br /&gt;
|-&lt;br /&gt;
| 'setPlayheadPosition'&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;AOD (or ad ): || current position in seconds (integer) &amp;lt;br/&amp;gt;&lt;br /&gt;
*&amp;quot;Live: current Unix timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position in seconds	|| Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| This event has to be called once for the current audio asset at the end of the playback.&lt;br /&gt;
At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Playhead position as integer&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' has to be called every second&lt;br /&gt;
&lt;br /&gt;
==== Example Events ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass ( Object ):''' Content Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', contentMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass  ( Object ):''' Pre-roll AD Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', prerollMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' setPlayheadPosition  |  '''Value Pass ( Integer ):''' playheadPosition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' stop  |  '''Value Pass ( Integer ):''' stopPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('stop', stopPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' end  |  '''Value Pass ( Integer ):''' endPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('end', endPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Interrupt Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== Pause Event ===&lt;br /&gt;
To indicate pause&lt;br /&gt;
&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending pings – [[loadMetadata]] and [[playheadPosition]] - once the playback resumes.&lt;br /&gt;
&lt;br /&gt;
=== Other Interrupt Scenarios ===&lt;br /&gt;
The following possible browser interruption scenarios must be handled:&lt;br /&gt;
&lt;br /&gt;
* Browser/Tab close&lt;br /&gt;
* Leaving the page to another destination&lt;br /&gt;
* Pressing the stop button&lt;br /&gt;
&lt;br /&gt;
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var stopped = false;&lt;br /&gt;
function closePlayer() {&lt;br /&gt;
	if (stopped) {return;}&lt;br /&gt;
	stopped = true;&lt;br /&gt;
	if (inMidroll) {    // Only inside a midroll indicate &amp;lt;stop&amp;gt; for the ad&lt;br /&gt;
		nSdkInstance.ggPM('stop', playheadPositionMidroll);&lt;br /&gt;
	}&lt;br /&gt;
	nSdkInstance.ggPM('end', playheadPositionContent);    // Indicate &amp;lt;end&amp;gt; for the content&lt;br /&gt;
};&lt;br /&gt;
window.addEventListener(&amp;quot;beforeunload&amp;quot;, function (e) {&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
window.addEventListener(&amp;quot;pagehide&amp;quot;, function (e) {	// for iOS mobile &amp;quot;pagehide&amp;quot; recommended by apple&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note:''' User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use &amp;quot;onpagehide&amp;quot; event as well).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  SDK Event Lifecycle ==&lt;br /&gt;
&lt;br /&gt;
The sample event lifecycle can be used as a reference for identifying the order for calling events.&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle without ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:even browser no ads.png]]&lt;br /&gt;
&lt;br /&gt;
==== Example without ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);  // must be called as start of stream&lt;br /&gt;
&lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playheads every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle with ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:event browser.png|event browser.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example with ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)&lt;br /&gt;
 &lt;br /&gt;
// PREROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end pre-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);&lt;br /&gt;
&lt;br /&gt;
// MIDROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
  &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end mid-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); &lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// POSTROLL&lt;br /&gt;
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.&lt;br /&gt;
&lt;br /&gt;
'''Note :''' For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll&lt;br /&gt;
&lt;br /&gt;
== Nielsen Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.&lt;br /&gt;
* A notice that the player includes proprietary measurement software that allows users to contribute to market research (such as Nielsen TV Ratings).&lt;br /&gt;
* A link to the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.&lt;br /&gt;
On the Nielsen Digital Measurement Privacy Policy page, users can click Choices to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen online measurement, click a link to receive an opt-out cookie.&lt;br /&gt;
&lt;br /&gt;
The following paragraph is a template for an opt-out statement.&lt;br /&gt;
&lt;br /&gt;
''The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen TV Ratings. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.''&lt;br /&gt;
&lt;br /&gt;
====Opt Back In====&lt;br /&gt;
&lt;br /&gt;
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'debug'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&lt;br /&gt;
====Example Production Initialization Call ====&lt;br /&gt;
Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;, &amp;quot;myPlayerName&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6421</id>
		<title>DCR Italy AUDIO Browser SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6421"/>
		<updated>2023-07-17T07:05:19Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Video Content Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings ([[DCR &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:&lt;br /&gt;
*Site launch events and how long page is viewed&lt;br /&gt;
*Time of viewing a sub section / page.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To get started, an App ID is needed. The App ID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  apid: &amp;quot;XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure SDK ==&lt;br /&gt;
There are two steps required for configuring the SDK:&lt;br /&gt;
*Add Static Queue Snippet&lt;br /&gt;
*Create SDK Instance&lt;br /&gt;
&lt;br /&gt;
=== Add Static Queue Snippet ===&lt;br /&gt;
Add the following script tag to the website:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
!function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.&lt;br /&gt;
&lt;br /&gt;
===Create SDK Instance===&lt;br /&gt;
To initialize the SDK, create an SDK instance by making the initialization API call:&lt;br /&gt;
&lt;br /&gt;
==== Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
NOLBUNDLE.nlsQ(&amp;quot;&amp;lt;apid&amp;gt;&amp;quot;, &amp;quot;&amp;lt;instanceName&amp;gt;&amp;quot;,{nol_sdkDebug: &amp;quot;debug&amp;quot;})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating an instance, pass the following  values:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter	!! Description	!! Required !! Values&lt;br /&gt;
|-&lt;br /&gt;
| apid	&lt;br /&gt;
|| Unique ID assigned to player/site. &lt;br /&gt;
*Test: begins with ‘T’ and is used for testing &lt;br /&gt;
*Production: begins with ‘P’ and is used in live environment when testing and certification is completed&lt;br /&gt;
||Yes||'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'&lt;br /&gt;
|-&lt;br /&gt;
|instanceName ||	Name of SDK instance ||Yes	 ||	&amp;quot;any string value&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_sdkDebug	|| Enables Nielsen console logging. Only required for testing	||Optional	|| nol_sdkDebug: &amp;quot;debug&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the initialization call is made, a unique static configuration file, &amp;lt;apid&amp;gt;.js, will be downloaded based on the apid and will be cached on the user’s browser.&lt;br /&gt;
&lt;br /&gt;
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”.&lt;br /&gt;
&lt;br /&gt;
==== Example SDK Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example SDK Configuration ===&lt;br /&gt;
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
  // Add Static Queue Snippet&lt;br /&gt;
 !function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Created SDK Instance&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;&amp;quot;true&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  isAudio:        'true',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
Don't pass audio key &amp;quot;isAudio&amp;quot; into the loadmetadata call.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata Object ===&lt;br /&gt;
The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type	|| type of ad	|| 'preroll', 'midroll', or 'postroll' ||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create pre-roll ad object&lt;br /&gt;
var prerollMetadataObject = &lt;br /&gt;
{  &lt;br /&gt;
  assetid: 'AD-1',&lt;br /&gt;
  type:    'preroll'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
The method for calling events is ggPM().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
nSdkInstance.ggPM('event', parameter);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
The events are included in the table below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event name !! Values to pass !!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each content/ad metadata object&lt;br /&gt;
|-&lt;br /&gt;
| 'setPlayheadPosition'&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;AOD (or ad ): || current position in seconds (integer) &amp;lt;br/&amp;gt;&lt;br /&gt;
*&amp;quot;Live: current Unix timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position in seconds	|| Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| This event has to be called once for the current audio asset at the end of the playback.&lt;br /&gt;
At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Playhead position as integer&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' has to be called every second&lt;br /&gt;
&lt;br /&gt;
==== Example Events ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass ( Object ):''' Content Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', contentMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass  ( Object ):''' Pre-roll AD Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', prerollMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' setPlayheadPosition  |  '''Value Pass ( Integer ):''' playheadPosition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' stop  |  '''Value Pass ( Integer ):''' stopPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('stop', stopPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' end  |  '''Value Pass ( Integer ):''' endPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('end', endPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Interrupt Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== Pause Event ===&lt;br /&gt;
To indicate pause&lt;br /&gt;
&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending pings – [[loadMetadata]] and [[playheadPosition]] - once the playback resumes.&lt;br /&gt;
&lt;br /&gt;
=== Other Interrupt Scenarios ===&lt;br /&gt;
The following possible browser interruption scenarios must be handled:&lt;br /&gt;
&lt;br /&gt;
* Browser/Tab close&lt;br /&gt;
* Leaving the page to another destination&lt;br /&gt;
* Pressing the stop button&lt;br /&gt;
&lt;br /&gt;
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var stopped = false;&lt;br /&gt;
function closePlayer() {&lt;br /&gt;
	if (stopped) {return;}&lt;br /&gt;
	stopped = true;&lt;br /&gt;
	if (inMidroll) {    // Only inside a midroll indicate &amp;lt;stop&amp;gt; for the ad&lt;br /&gt;
		nSdkInstance.ggPM('stop', playheadPositionMidroll);&lt;br /&gt;
	}&lt;br /&gt;
	nSdkInstance.ggPM('end', playheadPositionContent);    // Indicate &amp;lt;end&amp;gt; for the content&lt;br /&gt;
};&lt;br /&gt;
window.addEventListener(&amp;quot;beforeunload&amp;quot;, function (e) {&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
window.addEventListener(&amp;quot;pagehide&amp;quot;, function (e) {	// for iOS mobile &amp;quot;pagehide&amp;quot; recommended by apple&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note:''' User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use &amp;quot;onpagehide&amp;quot; event as well).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  SDK Event Lifecycle ==&lt;br /&gt;
&lt;br /&gt;
The sample event lifecycle can be used as a reference for identifying the order for calling events.&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle without ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:even browser no ads.png]]&lt;br /&gt;
&lt;br /&gt;
==== Example without ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);  // must be called as start of stream&lt;br /&gt;
&lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playheads every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle with ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:event browser.png|event browser.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example with ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)&lt;br /&gt;
 &lt;br /&gt;
// PREROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end pre-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);&lt;br /&gt;
&lt;br /&gt;
// MIDROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
  &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end mid-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); &lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// POSTROLL&lt;br /&gt;
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.&lt;br /&gt;
&lt;br /&gt;
'''Note :''' For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll&lt;br /&gt;
&lt;br /&gt;
== Nielsen Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.&lt;br /&gt;
* A notice that the player includes proprietary measurement software that allows users to contribute to market research (such as Nielsen TV Ratings).&lt;br /&gt;
* A link to the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.&lt;br /&gt;
On the Nielsen Digital Measurement Privacy Policy page, users can click Choices to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen online measurement, click a link to receive an opt-out cookie.&lt;br /&gt;
&lt;br /&gt;
The following paragraph is a template for an opt-out statement.&lt;br /&gt;
&lt;br /&gt;
''The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen TV Ratings. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.''&lt;br /&gt;
&lt;br /&gt;
====Opt Back In====&lt;br /&gt;
&lt;br /&gt;
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'debug'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&lt;br /&gt;
====Example Production Initialization Call ====&lt;br /&gt;
Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;, &amp;quot;myPlayerName&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6420</id>
		<title>DCR Italy AUDIO Browser SDK</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=DCR_Italy_AUDIO_Browser_SDK&amp;diff=6420"/>
		<updated>2023-07-17T07:03:10Z</updated>

		<summary type="html">&lt;p&gt;WilsonQuispe: /* Create Metadata Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International DCR}}  {{CurrentBreadcrumb}}&lt;br /&gt;
[[Category:Digital]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings ([[DCR &amp;amp; DTVR]]), [[Digital Ad Ratings]] (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:&lt;br /&gt;
*Site launch events and how long page is viewed&lt;br /&gt;
*Time of viewing a sub section / page.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
To get started, an App ID is needed. The App ID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  apid: &amp;quot;XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configure SDK ==&lt;br /&gt;
There are two steps required for configuring the SDK:&lt;br /&gt;
*Add Static Queue Snippet&lt;br /&gt;
*Create SDK Instance&lt;br /&gt;
&lt;br /&gt;
=== Add Static Queue Snippet ===&lt;br /&gt;
Add the following script tag to the website:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
!function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.&lt;br /&gt;
&lt;br /&gt;
===Create SDK Instance===&lt;br /&gt;
To initialize the SDK, create an SDK instance by making the initialization API call:&lt;br /&gt;
&lt;br /&gt;
==== Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
NOLBUNDLE.nlsQ(&amp;quot;&amp;lt;apid&amp;gt;&amp;quot;, &amp;quot;&amp;lt;instanceName&amp;gt;&amp;quot;,{nol_sdkDebug: &amp;quot;debug&amp;quot;})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating an instance, pass the following  values:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameter	!! Description	!! Required !! Values&lt;br /&gt;
|-&lt;br /&gt;
| apid	&lt;br /&gt;
|| Unique ID assigned to player/site. &lt;br /&gt;
*Test: begins with ‘T’ and is used for testing &lt;br /&gt;
*Production: begins with ‘P’ and is used in live environment when testing and certification is completed&lt;br /&gt;
||Yes||'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'&lt;br /&gt;
|-&lt;br /&gt;
|instanceName ||	Name of SDK instance ||Yes	 ||	&amp;quot;any string value&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| nol_sdkDebug	|| Enables Nielsen console logging. Only required for testing	||Optional	|| nol_sdkDebug: &amp;quot;debug&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the initialization call is made, a unique static configuration file, &amp;lt;apid&amp;gt;.js, will be downloaded based on the apid and will be cached on the user’s browser.&lt;br /&gt;
&lt;br /&gt;
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”.&lt;br /&gt;
&lt;br /&gt;
==== Example SDK Initialization API Call ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example SDK Configuration ===&lt;br /&gt;
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
  // Add Static Queue Snippet&lt;br /&gt;
 !function(t,n)&lt;br /&gt;
{&lt;br /&gt;
  t[n]=t[n]||&lt;br /&gt;
  {&lt;br /&gt;
    nlsQ:function(e,o,c,r,s,i)&lt;br /&gt;
    {&lt;br /&gt;
     return s=t.document,&lt;br /&gt;
     r=s.createElement(&amp;quot;script&amp;quot;),&lt;br /&gt;
     r.async=1,&lt;br /&gt;
     r.src=(&amp;quot;http:&amp;quot;===t.location.protocol?&amp;quot;http:&amp;quot;:&amp;quot;https:&amp;quot;)+&amp;quot;//cdn-gl.imrworldwide.com/conf/&amp;quot;+e+&amp;quot;.js#name=&amp;quot;+o+&amp;quot;&amp;amp;ns=&amp;quot;+n,&lt;br /&gt;
     i=s.getElementsByTagName(&amp;quot;script&amp;quot;)[0],&lt;br /&gt;
     i.parentNode.insertBefore(r,i),&lt;br /&gt;
     t[n][o]=t[n][o]||{g:c||{},&lt;br /&gt;
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
(window,&amp;quot;NOLBUNDLE&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  // Created SDK Instance&lt;br /&gt;
 var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;,&amp;quot;myPlayerName&amp;quot;, {nol_sdkDebug: &amp;quot;DEBUG&amp;quot;});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create Metadata Objects ==&lt;br /&gt;
There are two types of asset metadata:&lt;br /&gt;
*content: identify audio /video&lt;br /&gt;
*ad: identify each ad&lt;br /&gt;
&lt;br /&gt;
The metadata received for each asset is used for classification and reporting.&lt;br /&gt;
&lt;br /&gt;
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.&lt;br /&gt;
&lt;br /&gt;
==== Audio Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| isAudio || indicate measurement of audio ads or audio content || &amp;lt;code&amp;gt;&amp;quot;true&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Audio Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  isAudio:        'true',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Video Content Metadata ====&lt;br /&gt;
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Key !! Description !!	Values	 !! Required&lt;br /&gt;
|-&lt;br /&gt;
| type ||	Type of asset	|| &amp;lt;code&amp;gt;&amp;quot;content&amp;quot;&amp;lt;/code&amp;gt; || ✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid	|| Unique ID assigned to content (32 character limit)  || custom &amp;lt;br&amp;gt;(no [[Special Characters]])|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| program	|| Name of program (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| title	|| Episode title (100 characters limit)	|| custom	|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| length	|| Length of content in seconds  ||&lt;br /&gt;
Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For AOD video length)&lt;br /&gt;
||	&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
| airdate	|| The airdate in the linear over-the-air broadcast. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot; ||	YYYYMMDD hh:mm:ss &lt;br /&gt;
(if not known set it to eg. &amp;quot;19700101 00:00:00&amp;quot;) &lt;br /&gt;
|| ✓&lt;br /&gt;
|-&lt;br /&gt;
| isfullepisode	|| Full episode flag ||	&lt;br /&gt;
*&amp;quot;y&amp;quot;– full episode&lt;br /&gt;
*&amp;quot;n&amp;quot;– non full episode	&lt;br /&gt;
||&lt;br /&gt;
✓&lt;br /&gt;
|-&lt;br /&gt;
|adloadtype	|| type of ad load:&lt;br /&gt;
* 1) Linear – matches over-the-air ad load &lt;br /&gt;
* 2) Dynamic – Dynamic Ad Insertion (DAI)&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;1&amp;quot; – content with linear ads &lt;br /&gt;
*&amp;quot;2&amp;quot; – content with dynamic ads	&lt;br /&gt;
||&lt;br /&gt;
✓ (has to be &amp;quot;2&amp;quot; for DCR/Italy)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Video Content Object =====&lt;br /&gt;
&lt;br /&gt;
'''Note:''' all parameters should be provided as strings (also length)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create content object&lt;br /&gt;
var contentMetadataObject =&lt;br /&gt;
{  &lt;br /&gt;
  type:           'content',&lt;br /&gt;
  assetid:        'VID123-123456',&lt;br /&gt;
  program:        'program name',&lt;br /&gt;
  title:          'episode title',&lt;br /&gt;
  length:         '1020',    // length in seconds (String)&lt;br /&gt;
  airdate:        '19700101 00:00:00',&lt;br /&gt;
  isfullepisode:  'y',&lt;br /&gt;
  adloadtype:     '2'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ad Metadata Object ===&lt;br /&gt;
The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Keys	!! Description	!! Values	!! Required&lt;br /&gt;
|-&lt;br /&gt;
| type	|| type of ad	|| 'preroll', 'midroll', or 'postroll' ||	✓&lt;br /&gt;
|-&lt;br /&gt;
| assetid ||	unique ID assigned to ad	|| custom	|| ✓&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Example Ad Object ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//create pre-roll ad object&lt;br /&gt;
var prerollMetadataObject = &lt;br /&gt;
{  &lt;br /&gt;
  assetid: 'AD-1',&lt;br /&gt;
  type:    'preroll'&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Call Nielsen APIs ==&lt;br /&gt;
The method for calling events is ggPM().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
nSdkInstance.ggPM('event', parameter);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
The events are included in the table below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Event name !! Values to pass !!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 'loadMetadata'	|| content/ad metadata object	|| Needs to be called at the beginning of each content/ad metadata object&lt;br /&gt;
|-&lt;br /&gt;
| 'setPlayheadPosition'&lt;br /&gt;
||&lt;br /&gt;
*&amp;quot;AOD (or ad ): || current position in seconds (integer) &amp;lt;br/&amp;gt;&lt;br /&gt;
*&amp;quot;Live: current Unix timestamp (seconds since Jan-1-1970 UTC) &amp;lt;br/&amp;gt;&lt;br /&gt;
||&lt;br /&gt;
Pass playhead position every second during playback&lt;br /&gt;
|-&lt;br /&gt;
| 'stop' ||	playhead position in seconds	|| Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop&lt;br /&gt;
|-&lt;br /&gt;
| 'end'	|| playhead position in seconds	|| This event has to be called once for the current audio asset at the end of the playback.&lt;br /&gt;
At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Playhead position as integer&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' has to be called every second&lt;br /&gt;
&lt;br /&gt;
==== Example Events ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass ( Object ):''' Content Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', contentMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' loadMetadata  |  '''Value Pass  ( Object ):''' Pre-roll AD Metadata Object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('loadMetadata', prerollMetadataObject); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' setPlayheadPosition  |  '''Value Pass ( Integer ):''' playheadPosition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' stop  |  '''Value Pass ( Integer ):''' stopPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('stop', stopPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Event:''' end  |  '''Value Pass ( Integer ):''' endPlayheadPosition &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  nSdkInstance.ggPM('end', endPlayheadPosition); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Interrupt Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== Pause Event ===&lt;br /&gt;
To indicate pause&lt;br /&gt;
&lt;br /&gt;
* Call [[stop]] immediately and withhold sending playhead position.&lt;br /&gt;
* Start sending pings – [[loadMetadata]] and [[playheadPosition]] - once the playback resumes.&lt;br /&gt;
&lt;br /&gt;
=== Other Interrupt Scenarios ===&lt;br /&gt;
The following possible browser interruption scenarios must be handled:&lt;br /&gt;
&lt;br /&gt;
* Browser/Tab close&lt;br /&gt;
* Leaving the page to another destination&lt;br /&gt;
* Pressing the stop button&lt;br /&gt;
&lt;br /&gt;
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var stopped = false;&lt;br /&gt;
function closePlayer() {&lt;br /&gt;
	if (stopped) {return;}&lt;br /&gt;
	stopped = true;&lt;br /&gt;
	if (inMidroll) {    // Only inside a midroll indicate &amp;lt;stop&amp;gt; for the ad&lt;br /&gt;
		nSdkInstance.ggPM('stop', playheadPositionMidroll);&lt;br /&gt;
	}&lt;br /&gt;
	nSdkInstance.ggPM('end', playheadPositionContent);    // Indicate &amp;lt;end&amp;gt; for the content&lt;br /&gt;
};&lt;br /&gt;
window.addEventListener(&amp;quot;beforeunload&amp;quot;, function (e) {&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
window.addEventListener(&amp;quot;pagehide&amp;quot;, function (e) {	// for iOS mobile &amp;quot;pagehide&amp;quot; recommended by apple&lt;br /&gt;
	closePlayer();   // call nielsensdk with end/stop&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;'''Note:''' User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use &amp;quot;onpagehide&amp;quot; event as well).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  SDK Event Lifecycle ==&lt;br /&gt;
&lt;br /&gt;
The sample event lifecycle can be used as a reference for identifying the order for calling events.&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle without ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:even browser no ads.png]]&lt;br /&gt;
&lt;br /&gt;
==== Example without ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);  // must be called as start of stream&lt;br /&gt;
&lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playheads every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Event Lifecycle with ads: ====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:event browser.png|event browser.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example with ads: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// START OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)&lt;br /&gt;
 &lt;br /&gt;
// PREROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end pre-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);&lt;br /&gt;
&lt;br /&gt;
// MIDROLL&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
  &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);  // end mid-roll stream&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// CONTENT&lt;br /&gt;
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); &lt;br /&gt;
nSdkInstance.ggPM('end', endPlayheadPosition);  // has to be called here at the end of the content&lt;br /&gt;
// endPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
 &lt;br /&gt;
// POSTROLL&lt;br /&gt;
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);&lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);  // must be fired every second with playhead starting from 0&lt;br /&gt;
&lt;br /&gt;
... /*** pass playhead every second ***/&lt;br /&gt;
 &lt;br /&gt;
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream&lt;br /&gt;
// END OF STREAM&lt;br /&gt;
nSdkInstance.ggPM('stop', stopPlayheadPosition);  // stopPlayheadPosition = lastPlayheadPosition&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.&lt;br /&gt;
&lt;br /&gt;
'''Note :''' For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll&lt;br /&gt;
&lt;br /&gt;
== Nielsen Opt-Out ==&lt;br /&gt;
&lt;br /&gt;
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.&lt;br /&gt;
* A notice that the player includes proprietary measurement software that allows users to contribute to market research (such as Nielsen TV Ratings).&lt;br /&gt;
* A link to the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.&lt;br /&gt;
On the Nielsen Digital Measurement Privacy Policy page, users can click Choices to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen online measurement, click a link to receive an opt-out cookie.&lt;br /&gt;
&lt;br /&gt;
The following paragraph is a template for an opt-out statement.&lt;br /&gt;
&lt;br /&gt;
''The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen TV Ratings. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://global.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=it.''&lt;br /&gt;
&lt;br /&gt;
====Opt Back In====&lt;br /&gt;
&lt;br /&gt;
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.&lt;br /&gt;
&lt;br /&gt;
== Going Live ==&lt;br /&gt;
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.&lt;br /&gt;
# '''Debug Logging''': Disable logging by deleting &amp;lt;code&amp;gt;{nol_sdkDebug: 'debug'}&amp;lt;/code&amp;gt; from initialization call.&lt;br /&gt;
&lt;br /&gt;
====Example Production Initialization Call ====&lt;br /&gt;
Refer to the production initialization call below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;var nSdkInstance = NOLBUNDLE.nlsQ(&amp;quot;P14273221-CF5C-46BF-A832-994AEFB73AA4&amp;quot;, &amp;quot;myPlayerName&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>WilsonQuispe</name></author>
	</entry>
</feed>