<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nielsentest.mywikis.net/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AiOS_NielsenAppSDKJSHandler</id>
	<title>Template:iOS NielsenAppSDKJSHandler - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nielsentest.mywikis.net/w/index.php?action=history&amp;feed=atom&amp;title=Template%3AiOS_NielsenAppSDKJSHandler"/>
	<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=Template:iOS_NielsenAppSDKJSHandler&amp;action=history"/>
	<updated>2026-04-17T01:27:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://nielsentest.mywikis.net/w/index.php?title=Template:iOS_NielsenAppSDKJSHandler&amp;diff=5194&amp;oldid=prev</id>
		<title>ColinBrown: Created page with &quot;== Using the NielsenAppSDKJSHandler == There could be a scenario in which a browser page, that is already tagged with the Nielsen BSDK, needs to be loaded via a webview.  In t...&quot;</title>
		<link rel="alternate" type="text/html" href="https://nielsentest.mywikis.net/w/index.php?title=Template:iOS_NielsenAppSDKJSHandler&amp;diff=5194&amp;oldid=prev"/>
		<updated>2021-08-23T21:11:20Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Using the NielsenAppSDKJSHandler == There could be a scenario in which a browser page, that is already tagged with the Nielsen BSDK, needs to be loaded via a webview.  In t...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Using the NielsenAppSDKJSHandler ==&lt;br /&gt;
There could be a scenario in which a browser page, that is already tagged with the Nielsen BSDK, needs to be loaded via a webview.  In this situation it is recommended to use the '''NielsenAppSDKJSHandler''' which will allow communication between the AppSDK and the BSDK. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''This feature is supported in versions 7.2 and above.'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
* Make sure you have the latest NielsenAppApi.framework from Nielsen containing the NielsenAppSDKJSHandler class.&lt;br /&gt;
* Add NielsenAppSDKJSHandler instance as web view message handler object conforming to WKScriptMessageHandler protocol with name: &amp;quot;NielsenSDKMsg&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Objective-C:'''&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=Objective-c&amp;gt;&lt;br /&gt;
self.jsAppSDK = [[NielsenAppSDKJSHandler alloc] init];&lt;br /&gt;
[self.webView.configuration.userContentController addScriptMessageHandler:self.jsAppSDK name:@&amp;quot;NielsenSDKMsg&amp;quot;];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Swift:'''&lt;br /&gt;
 &amp;lt;syntaxhighlight lang=Swift&amp;gt;&lt;br /&gt;
self.jsAppSDK=NielsenAppSDKJSHandler(apiType: &amp;quot;ggPM&amp;quot;)&lt;br /&gt;
if let jsAppSDK = self.jsAppSDK{&lt;br /&gt;
   self.webView?.configuration.userContentController.add(jsAppSDK, name: &amp;quot;NielsenSDKMsg&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This will enable listening to BSDK api calls within the APPSDK.  Please make sure your Technical Account Manager is aware that you wish to implement this method so a configuration file can be modified on the Nielsen servers; however, there are '''no changes required to the Browser page'''.&lt;br /&gt;
&lt;br /&gt;
==== Example:====&lt;br /&gt;
The below is an example of opening a webview with the NielsenApp[SDKJSHandler using Swift 5.0&lt;br /&gt;
&amp;lt;syntaxhighlight lang=java&amp;gt;&lt;br /&gt;
  let jsFunctionNativeMessage = &amp;quot;NielsenSDKMsg&amp;quot;&lt;br /&gt;
  var jsAppSDK: NielsenAppSDKJSHandler?&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;
&lt;br /&gt;
        let url = URL(string: &amp;quot;https://nielsen.com/index.htm&amp;quot;)!&lt;br /&gt;
        self.jsAppSDK=NielsenAppSDKJSHandler(apiType: &amp;quot;ggPM&amp;quot;)&lt;br /&gt;
        if let jsAppSDK = self.jsAppSDK{&lt;br /&gt;
            self.webView?.configuration.userContentController.add(jsAppSDK, name: &amp;quot;NielsenSDKMsg&amp;quot;)&lt;br /&gt;
            webView.load(URLRequest(url: url))&lt;br /&gt;
            webView.allowsBackForwardNavigationGestures = true&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
    deinit {&lt;br /&gt;
        if let webView = self.webView {&lt;br /&gt;
            webView.configuration.userContentController.removeScriptMessageHandler(forName: jsFunctionNativeMessage)&lt;br /&gt;
        }&lt;br /&gt;
        self.jsAppSDK = nil&lt;br /&gt;
        if let webView = self.webView {&lt;br /&gt;
            webView.removeFromSuperview()&lt;br /&gt;
        }&lt;br /&gt;
        self.webView = nil&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Please note:  The page you load into the webview cannot have mixed protocol content.  For example, if your page is https:// you cannot have any images on the page as http:// or you will encounter errors.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ColinBrown</name></author>
	</entry>
</feed>