DTVR Android SDK: Difference between revisions

From Engineering Client Portal

No edit summary
(adModel)
Line 34: Line 34:
<syntaxhighlight lang="json">    {
<syntaxhighlight lang="json">    {
       "type": "content",
       "type": "content",
       "adloadtype": "1"
       "adModel": "1"
     }</syntaxhighlight>
     }</syntaxhighlight>



Revision as of 22:09, 8 November 2017

Engineering Portal / Digital / DCR & DTVR / DTVR Android SDK

Prerequisites

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

  • App ID (appid): Unique ID assigned to the player/site and configured by product.
  • sfcode: Unique identifier for the environment that the SDK should point to.
  • Nielsen SDK and Sample Player: A part of the downloaded package

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

Import Library

Refer to Android SDK API Reference - Setting Up Development Environment for information on importing libraries.

  • The latest version of App SDK allows instantiating multiple instances of App SDK object and can be used simultaneously without any issues.

Note: The latest version of App SDK contains only appsdk.jar file and does not feature any native shared libraries like libAppSdk.so.

Initialize SDK

Initialize App SDK as soon as the application is launched. Refer to Android SDK API Reference - Initialization for details on initializing an AppSDK object and the parameters required.

Configure and fire API calls

Configure API calls - play

Call play() when starting or resuming a streaming session to pass the channel descriptor information through channelName parameter when the user taps the Play button on the player.

  • channelName is a 32-character free-form text field containing the name of the program or feed being sent (such as ESPN2, Food Network, etc.)

Call play() with channelName JSON as below.

    {
      "channelName": "TheMovieTitle"
    }

Configure API calls - loadMetadata

Load the CMS metadata by calling loadMetadata() on the SDK object.

    loadMetadata(JSONObject jsonMetadata);

Refer to Digital Measurement Metadata for the list of parameters to be passed in the JSON object. Call loadMetadata() for the content after the first play() call. Call loadMetadata() with JSON metadata for the active content as below.

    {
      "type": "content",
      "adModel": "1"
    }

Configure API calls - sendID3

sendID3() API is a receiver for HLS timed metadata events (ID3 tags) provided through the notification system. This API filters out Nielsen-specific ID3 tags from the system and buffers the data for transfer to Nielsen’s collection facility. Call sendID3() whenever new Nielsen ID3 metadata is available for processing during session playback.

Sample ID3 tags

  • www.nielsen.com/X100zdCIGeIlgZnkYj6UvQ==/X100zdCIGeIlgZnkYj6UvQ==/AAAB2Jz2_k74GXSzx4npHuI_JwJd3QSUpW30rDkGTcbHEzIMWleCzM-uvNOP9fzJcQMWQLJqzXMCAxParOb5sGijSV9dNM3QiBniJYGZ5GI-lL1fXTTN0IgZ4iWBmeRiPpS9AAAAAAAAAAAAAAAAAAAAAFJWFM5SVhTONNU=/00000/00000/00
  • www.nielsen.com/X100zdCIGeIlgZnkYj6UvQ==/R8WHe7pEBeqBhu8jTeXydg==/AAICoyitYqlxT7n6aZ0oMCGheFi4CXFp46AMUPZz1lMr_M9tr3_cjee1SHqxrOiVerMDLeyn9xzocZSKwi746Re8vNOtpNCAZjYABs_J0R25IHpvOc1HS8QHGgD5TgOJeS6gX100zdCIGeIlgZnkYj6UvVJWFNhSVhTiPE0=/00000/46016/00

Note: ID3 tags are not applicable for International (Germany)

Refer to Android SDK API Reference - Retrieving ID3 Tags section to know more details.

Configure API calls - stop

Call stop() only when the stream playback is stopped by a user. Common events are; network loss, power / standby, incoming call, alarm, etc. Call stop() only when buffering continues for 30 seconds (not when it starts). Call play() when resuming a stream (previously stopped) or starting playback of a new stream.

Configure API calls - end

Call end() only at the end of playback. Not mandatory if stream is live/does not end.

API Call sequence

Use Case 1: Content has no Advertisements

Call play() with channelName JSON as below:

    {
        "channelName": "TheMovieTitle"
    }

Use Case 2: Content has linear (non-DAI) Advertisements

Call play() (for the first ad) with channelName JSON as below:

    {
        "channelName": "TheMovieTitle"
    }

Call loadMetadata() with JSON metadata for the active content as below:

    {
        "adloadtype": "1"
    }

Call sendID3() with ID3 payload

    sendID3(payload)

Handling Foreground and Background states of App

There are two ways of handling the foreground and background states of the client application.

  • Let App SDK handle the app states information (foreground / background) and use it, as necessary.
  • Capture app states through the application and trigger the corresponding API (appInForeground() or appInBackground()) upon every change of state. This allows Nielsen App SDK to know the app state.

New devices (Android 4.0 and later versions)

Add application tag to Manifest XML file When a client’s app supports only new devices (Android 4.0 and above) and the client has not implemented a custom Application class for some other purpose,

  • Add the following entry (application tag) into the Manifest XML file to use SDK’s state detection feature.
   <application android:name="com.nielsen.app.sdk.AppSdkApplication">

This is the custom Application class where the whole background detection implementation is done. No new permissions are required to change the properties in Manifest XML file.

Older devices (Android 4.0 or earlier version)

Identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) upon every change of state (foreground / background). The SDK will use this information to pass the app launch times, etc. to Collection facility.

AppLaunchMeasurementManager.appInForeground(getApplicationContext());
AppLaunchMeasurementManager.appInBackground(getApplicationContext());

Interruptions during playback

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

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

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

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

Please see the Digital Measurement FAQ for more details

Nielsen Measurement Opt-Out Implementation

As a global information and measurement leader, we are committed to protecting the privacy and security of the data we collect, process and use. Our digital measurement products are not used to identify the consumer in any way, but they help us and our clients measure and analyze how consumers engage with media across online, mobile and emerging technologies, and offer insights into consumer behavior.

  • When the app user wants to opt in or opt out of Nielsen measurement, a new dynamic page (with content string obtained from userOptOutURLString()) should be displayed.
  • This Opt-out page should be displayed in a webview (within the app) and not in any external browser.
  • Capture the user’s selection in this page and pass it to the SDK through userOptOut() for Nielsen to save the user’s preference.
  • For more details, refer to Android SDK API Reference - Android Opt-Out Implementation and Nielsen Digital Privacy.

Testing an Implementation - App

See Digital Measurement Testing.