DCR Static Android SDK: Difference between revisions

From Engineering Client Portal

No edit summary
(Added sdkbgfgDetectionUtility)
Line 48: Line 48:


==== Handling Foreground and Background states of App ====
==== Handling Foreground and Background states of App ====
There are two ways of handling the foreground and background states of the client application.
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
* Let App SDK handle the app states information (foreground / background) and use it, as necessary. See [[#New_devices_.28Android_4.0_and_later_versions.29]] for more information.
* Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.
* 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. See [[#Older_devices_.28Android_4.0_or_earlier_versions.29]] for more information.
* Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.
* Custom implementation of the required methods within your application.


==== New devices (Android 4.0 and later versions) ====
=== ForeGround/Background Measurement via AndroidManifest ===
'''Add ''application'' tag to Manifest XML file'''
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.
When 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,
<syntaxhighlight lang="java">
* 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”>
<syntaxhighlight lang="java">   <application android:name="com.nielsen.app.sdk.AppSdkApplication"></syntaxhighlight>
</syntaxhighlight>
This is the custom Application class where the whole background detection implementation is done.
<blockquote>Note: No new permissions are required to change the properties in Manifest XML file.</blockquote>


==== Older devices (Android 4.0 or earlier versions) ====
=== Using the Android SdkBgFbDetectionUtility Class ===
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.
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.
<syntaxhighlight lang="java">   AppLaunchMeasurementManager.appInForeground(getApplicationContext());
 
    AppLaunchMeasurementManager.appInBackground(getApplicationContext());</syntaxhighlight>
=== Manual Background/ForeGround State Management ===
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.
 
The SDK is informed about app state using the below methods.
<syntaxhighlight lang="java">
AppLaunchMeasurementManager.appInForeground(getApplicationContext());
AppLaunchMeasurementManager.appInBackground(getApplicationContext());
</syntaxhighlight>
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.
 
 
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).


=== Nielsen Measurement Opt-Out Implementation ===
=== Nielsen Measurement Opt-Out Implementation ===

Revision as of 18:16, 8 November 2017

Engineering Portal / Digital / DCR & DTVR / DCR Static 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 guide 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.

Note: The integrator should always tag the landing page on the app.

Initialize SDK

Initialize App SDK as soon as the application is launched. Refer to Initalization for details on initializing an AppSDK object and the parameters required.

Configure API calls - play

For static <App Measurement> content, play API is not required.

Configure API calls - loadMetadata

Use loadMetadata to pass 'content' Digital Measurement Metadata. The CMS data must be passed as a JSON object.

    loadMetadata(JSONObject jsonMetadata);

Refer to Digital Measurement Metadata for the list of parameters to be passed in the JSON object.

Note: The loadMetadata call must have ("type": "static").

Configure API calls - playheadPosition

For static <App Measurement> content, no playhead has to be supplied to the SDK.

stop

For static <App Measurement> content, stop API is not required.

API Call sequence

Call loadMetadata with JSON metadata as below.

    new JSONObject()
        .put("type", "static")
        .put("section", "siteSection")
        .put("assetid", "vid345-67483")
        .put("segA", "segmentA")
        .put("segB", "segmentB")
        .put("segC","segmentC")
    }

Sdk dataflow.jpg

Handling Foreground and Background states of App

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

  • Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.
  • Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.
  • Custom implementation of the required methods within your application.

ForeGround/Background Measurement via AndroidManifest

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.

<application android:name=com.nielsen.app.sdk.AppSdkApplication>

Using the Android SdkBgFbDetectionUtility Class

For developers who are already using the application class, it is recommended that background/foreground state is implemented using the SdkBgFgDetectionUtility class. The SdkBgFgDetectionUtility class is compatible with Android 4+ and has been made available to Nielsen clients.

Manual Background/ForeGround State Management

In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided 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.

The SDK is informed about app state using the below methods.

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

Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.


Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).

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 optOutURL) should be displayed.
  • Use optOutStatus to retrieve the device’s Opt-Out status.
  • 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.

Pre-Certification Checklists

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

Testing an Implementation - App

See Digital Measurement Testing.