Difference between revisions of "DCR Germany Static Hybrid App SDK"

From Engineering Client Portal

(Created page with "{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|AGF Implementation Documentation}} {{CurrentBreadcrumb}} Category:Digital <pre style="color: red"> PLease note that t...")
 
 
Line 1: Line 1:
 
{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|AGF Implementation Documentation}}  {{CurrentBreadcrumb}}
 
{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|AGF Implementation Documentation}}  {{CurrentBreadcrumb}}
 
[[Category:Digital]]
 
[[Category:Digital]]
 
<pre style="color: red">
 
PLease note that this Hybrid App SDK Integration Guide is not yet released for AGF/Germany!
 
</pre>
 
  
 
== Overview ==
 
== Overview ==

Latest revision as of 07:26, 31 March 2023

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png AGF Implementation Documentation breadcrumbArrow.png DCR Germany Static Hybrid App SDK

Overview

The Nielsen App SDK is one of multiple framework SDKs that Nielsen provides to enable measuring linear (live) and on-demand TV viewing using TVs, mobile devices, etc. The App SDK is the framework for iOS and Android Apps developers to integrate Nielsen Measurement into their App for the Static Content Measurement.

This guide will show you how to enable Static measurement in the WebView of your Hybrid App. The Nielsen App Static Measurement of each different page/section requires different metadata.

Prerequisites

  • To get started, an AppID is needed. The AppID is a unique ID assigned to the App. This will be provided upon starting the integration from Nielsen.
  apid: "XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA
  • No ID AppSDK:

    ONLY the No ID AppSDK should be downloaded for the AGF market!
  • WebView page is tagged with Browser SDK:

    Make sure that the content loaded in the WebView of your App is already tagged with Nielsen Browser SDK!

Step 1: Set up your Development Environment

iOS

For setting up your iOS Development Environment, refer to DCR Germany Video App SDK#iOS

Android

NielsenAppSDKJSHandler in Android only supports Android X. Hence only get Android x enabled Appsdk.jar from Nielsen.

For setting up your Android Development Environment, refer to DCR Germany Video App SDK#Android


Step 2: Implement the Nielsen AppSDK JS Handler

Description

Tag every page with BSDK, BSDK will check for availability of AppSDK handler in the page before loading itself. On the native side, inject the webview with JS handler which listens the call from BSDK and relay it to AppSDK and vice versa On the native side, embed AppSDK in the App project, so that JS handler in webview can relay the calls from JS to native SDK interface.


Implementation

iOS

Add NielsenAppSDKJSHandler instance

Add NielsenAppSDKJSHandler instance as web view message handler object conforming to WKScriptMessageHandler protocol with name: "NielsenSDKMsg". That starts the listening to Browser SDK api calls in AppSDK.

Swift
self.jsAppSDK = NielsenAppSDKJSHandler(apiType: "ggPM") //  or apiType:"any string" or apiType:nil
if let jsAppSDK = self.jsAppSDK {
    self.webView?.configuration.userContentController.add(jsAppSDK, name: "NielsenSDKMsg")
}
Objective-C
    
self.jsAppSDK = [[NielsenAppSDKJSHandler alloc] initWithApiType:@"ggPM"]; // or initWithApiType:@"any string" or initWithApiType:nil
[self.webView.configuration.userContentController addScriptMessageHandler:self.jsAppSDK name:@"NielsenSDKMsg"];
@end

Please make sure that you don't use any other name than “NielsenSDKMsg” for adding WKScriptMessageHandler instance as javascript listener otherwise you won't receive BSDK api calls in APPSDK.


remove NielsenAppSDKJSHandler instance when WebView is being unloaded

To delete NielsenAppSDKJSHandler instance it should be detached from web view and pointer to it should be set to nil.

Swift
self.webView?.configuration.userContentController.removeScriptMessageHandler(forName: "NielsenSDKMsg")
self.jsAppSDK = nil
Objective-C
    
[self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"NielsenSDKMsg"];
self.jsAppSDK = nil;

Android

Enable the javascript on webview using below lines
WebSettings webSetting = webView.getSettings();
webSetting.setJavaScriptEnabled(true);
Add NielsenAppSDKJSHandler instance as javascript interface to webview with name “NielsenAppSDK”

That starts the listening to Browser SDK api calls in AppSDK.

webView.addJavascriptInterface(new NielsenAppSDKJSHandler(getApplicationContext()), "NielsenAppSDK");