AppSDK()

From Engineering Client Portal

Revision as of 00:06, 13 June 2024 by AmySockanathan (talk | contribs) (Changes to add luid parameter in SDK init for Android)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Engineering Portal / Digital / Android SDK API Reference / AppSDK()

AppSdk() is the public constructor used for initializing the App SDK Analytics framework.

  • The reference to the App SDK object returned by the Appsdk constructor.
  • App SDK supports multiple instances (max. four) to measure multiple players simultaneously.
  • context, appInfo parameters are mandatory and should not be NULL values.
  • The constructor should never return null.

Debug flag for development environment

Player application developers / integrators can use Debug flag to check whether an App SDK API call made is successful. To activate the Debug flag,

  • Pass the argument + ""nol_devDebug" : "" + "I" + "",", while initializing the App SDK object. The permitted values are
    • 'I' (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.
    • 'W' (WARNING): Indicates potential integration / configuration errors or SDK issues.
    • 'E' (ERROR): Indicates important integration errors or non-recoverable SDK issues.
    • 'D' (DEBUG): Debug logs, used by the developers to debug more complex issues.

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

Note: DO NOT activate the Debug flag in production evironment.

Syntax

public AppSdk(Context context, JSONObject appInfo, IAppNotifier notifier);

Input Parameters

Parameter Description
context The context from the App
appInfo JSON object that defines the application information.
notifier Client-provided object implementing the iAppNotifier interface. Can be ‘null’ if not provided by client.

Output Parameters

Output Parameters (Return value) Description
A reference to the instance. Else Null object

Notes

JSON object for appInfo

The complete list of arguments that can be passed via the AppInfo JSON schema for the API are as follows: (The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.)

Parameter / Argument Description Source Required? Example
appid Unique id for the application assigned by Nielsen. It is GUID data type.
  • Use Test appid during development, test, and certification processes
  • Use Production appid to submit app to App / Play store, after receiving Nielsen certification.
Nielsen-specified Yes PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
sfcode Nielsen collection facility to which the SDK should connect.

DTVR

  • "us" for production

DCR

  • "dcr" for production
Nielsen-specified Yes dcr
longitude This value will not be overwritten by SDK for International (Germany). Client-defined No 123.22
latitude This value will not be overwritten by SDK for International (Germany). Client-defined No -123.22
dma Nielsen Designated Market Area code. DMA must be the Nielsen DMA value. Please check with the Technical Account Manager. Client-defined No 123
ccode If Country Code is provided by the app, it should be done after consultation with the Technical Account Manager. Client-defined No 456
hem_sha256 SHA256-hashed email address (client-supplied unique 32-character hexadecimal string) Client-defined No tMmiiTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ=
hem_sha1 SHA1-hashed email address (client-supplied unique 32-character hexadecimal string) Client-defined No XvBniTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ=
hem_md5 MD5-hashed email address (client-supplied unique 32-character hexadecimal string) Client-defined No JnIbdTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ=
uid2 An identifier based on a user’s verifiable PII (e.g. hashed email). UID2.0 was initially created by The Trade Desk (TTD) and is now managed by Prebid. Client-defined No MTKVpUAzwYAPnHrtfE0wlINOMzhU7UUEjjVdCdRu63k=
uid2_token Encrypted Unified ID 2.0 Client-defined No AgAAAAPFR0zA5ogv/yaAPiUsAdZPsfqS8Ql

DSGxAB+rr8yekFs3AjLYVk5qqqiyV2XHbSuwzHmxSlLeQeK QI1mp015jsNnpX5/xGgXldcgVz+gFnyh3T8/3agMwRmyrhC xG4oH2C7fc48AQk2eotE7FW0ZDEYM8fD9ZxDaxFUC/OV3OuZA&

luid Living Unit ID - Experian Household ID

Note: This parameter is applicable only for CTV and First Party Livestream data

Client-defined No B0EOFEDgD


  JSONObject appSdkConfig = new JSONObject()
          .put("appid", "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
          .put("sfcode", "uat-cert")
          .put("custom_key1", "custom_value1")
          .put("custom_key2", "custom_value2");

// Pass appSdkConfig to the AppSdk constructor
mAppSdk = new AppSdk(appContext, appSdkConfig, appSdkListener);
}

JSON string format for appInfo

The required items are application ID (appid), designated market area (dma), Nielsen-assigned data node (sfcode), and the country code (ccode).

Note: Notice that all quotes inside the string are escaped with a backslash (\).

"{"appid":"PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX,"sfcode":"us"}"

iAppNotifier

Client apps can subscribe to the App SDK event listener to be notified about App SDK events. To implement this feature, create a plain old java object (POJO) that implements the interface com.nielsen.app.sdk.IAppNotifier. Do not implement with the main activity class as this creates a strong reference and interferes with memory release.

//pass the implementing object to the AppSdk constructor in order to subscribe to the eventlistener:
mAppSdk = new AppSdk(context, appInfo,iappNotifierObject)

Optionally, implement an object derived from the interface, as below. This object will allow listening for events within the App SDK.

public interface iAppNotifier
{
public void onAppSdkEvent(long timestamp, int code, String description);
}

Note that implementing the event listener is optional.

AppSdk events

There are three events currently exposed on the App SDK.

public static final int EVENT_INITIATE = 2000;
  • App SDK notifies that it is going to be initialized.
public static final int EVENT_STARTUP = 2001;
  • The App SDK has just started up. It will happen only after the App SDK has received a valid config file from Nielsen. This is the location in the code to acquire value of userOptOutURLString().
public static final int EVENT_SHUTDOWN = 2002;
  • The App SDK is shutting down. It will happen only when the App SDK is destroyed.