Template

iOS Privacy and Opt-Out: Difference between revisions

From Engineering Client Portal

No edit summary
 
(53 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Privacy and Opt-Out ==
== Privacy and Opt-Out ==
There are three primary methods for implementing user Opt-out preferences:
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Limit Ad Tracking'' setting on device ('''preferred approach''').
# '''[[#Legacy_Opt-out|Legacy Opt-out]]''' - Direct call to SDK; used only for older versions of Nielsen iOS SDK (< 5.1.1.18)
# '''[[#App_Level_Opt_Out|App Level Opt-Out]]''' - Where [https://developer.apple.com/documentation/adsupport Ad Framework] cannot be leveraged


=== OS-level Opt-out ===
There are currently 3 flavors of the Nielsen SDK. Please check the "Implementation" section for a comparison of the three flavors. Implementing opt-out for the three flavors are different:
''OS-level Opt-out'' method available on Nielsen iOS '''SDK Versions 5.1.1.18 and above'''.
# '''[[#Global_iOS_SDK_Opt-out|Global iOS SDK Opt-out]]''' - managed by ''AppTracking'' or ''Limit Ad Tracking'' setting on device.
# '''[[#Global_iOS_SDK_No_Ad_Framework_Opt-out|Global iOS SDK No Ad Framework Opt-out]]''' - Direct call to SDK. Can be used without the Ad Framework.
# '''[[#Global_iOS_SDK_No_ID_Opt-out|Global iOS SDK No ID Opt-out]]''' - Direct call to SDK. Should be used for Kids Category.
__NOTOC__
=== Global iOS SDK Opt-out ===
''OS-level Opt-out'' method available on Nielsen iOS  


The Nielsen SDK automatically leverages the iOS's ''Limit Ad Tracking'' setting. The user is opted out of demographic measurement if the OS-level ''"Limit Ad Tracking"'' setting is ''enabled''. As a publisher, you cannot override this setting.
The Nielsen SDK automatically leverages the iOS's '''Limit Ad Tracking''' or '''AppTracking''' setting.  
*  If the User's device is running < iOS 13.x, the Nielsen SDK will check the status of '''Limit Ad Tracking'''.
*  iOS14 modifies the way Apple manages the collection of a User's Opt-In status through '''AppTracking'''. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.
==== Webview Element ====
It is a requirement to display a WebView element whose loadUrl is set to the value obtained from optOutURL.
If using the Global iOS SDK, this optOutURL informs the user how to deactivate/activate “App Tracking/Limit Ad Tracking”.


=== Legacy Opt-out ===
The ''Legacy opt-out'' method is only necessary for Nielsen iOS '''SDK versions less than 5.1.1.18'''.


Nielsen iOS SDK 5.1.1.17 and above will check for ''OS-level opt-out'' first, if available. The user will be opted out if indicated at the OS-level '''OR''' the App-level.
If you are implementing on AppleTV here are your Opt Out verbiage options : https://engineeringportal.nielsen.com/docs/DCR_Video_%26_Static_CTV_Device_SDK_Privacy


==== The legacy opt-out method works as follows: ====
==== Sample Code for Global Build ====
* Get the legacy Nielsen opt-out URL via [[optOutURL]]
===== Swift =====
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]
<syntaxhighlight lang="swift">
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
import UIKit
** Opt-out if the WebView URL = <code>nielsenappsdk://1</code>
import WebKit
** Opt-in if the WebView URL = <code>nielsenappsdk://0</code>
import NielsenAppApi
* Pass the detected URL to the [[userOptOut]] function
** Example: <syntaxhighlight lang=swift>NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out</syntaxhighlight>


==== Legacy Opt-out example code ====
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
{{ExampleCode|
    var nielsenApi : NielsenAppApi!
|Objective C = <syntaxhighlight lang="objective-c">
    var webView: WKWebView!
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
 
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }


     NSURLRequest *request = [navigationAction request];
     override func viewDidLoad() {
    NSString *url = [[request URL]absoluteString];
         super.viewDidLoad()
   
    if([url isEqualToString:self.NIELSEN_URL_OPT_OUT] || [url isEqualToString:self.NIELSEN_URL_OPT_IN]){
         [self.nielsenApi userOptOut:url];
        decisionHandler(WKNavigationActionPolicyAllow);
    }else{
        decisionHandler(WKNavigationActionPolicyCancel);
    }       
}
</syntaxhighlight>
|Swift = <syntaxhighlight lang="swift">


var webView: WKWebView!
    if let appApi = self.nielsenApi {
var NIELSEN_URL_OPT_OUT : String = "nielsenappsdk://1"
            //Getting the optPut URL from SDK
var NIELSEN_URL_OPT_IN : String = "nielsenappsdk://0"
            if let url = URL(string: appApi.optOutURL) {
                webView.load(URLRequest(url: url))
                webView.allowsBackForwardNavigationGestures = true
            }}}


func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
        func closeOptOutView() {
 
            self.dismiss(animated: true, completion: nil)
      let urlStr = navigationAction.request.url?.absoluteString
        }}
</syntaxhighlight>


        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){
===== Objective-C =====
            let appApi = self.nielsenApi
<syntaxhighlight lang="objective-c">
            appApi?.userOptOut(urlStr)
            decisionHandler(.allow)


        }else{
#import "OptOutVC.h"
          decisionHandler(.cancel)
#import "NielsenInit.h"
        }
#import <NielsenAppApi/NielsenAppApi.h>
    }
</syntaxhighlight>
}}


=== Retrieve current Opt-Out preference ===
@interface OptOutVC ()
Whether the user is opted out via OS-level Opt-out or via App-level Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus]] property in the Nielsen SDK API


=== Required Privacy Links ===
@property (weak, nonatomic) IBOutlet UIWebView *webView;
Users must either have access to the "About Nielsen Measurement" page, or have similar text available within the native app. Include "About Nielsen Measurement" and "Your Choices" link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.
@end


In addition, the following text must be included in your app store description.
@implementation OptOutVC
<blockquote>
'''"Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see http://priv-policy.imrworldwide.com/priv/mobile/us/en/optout.html for more information"'''</blockquote>


==== Webview Example  ====
The below code is an example of displaying the Nielsen Privacy page to the user.
{{ExampleCode|
|Objective C = <syntaxhighlight lang="objective-c">
- (void)viewDidLoad {
- (void)viewDidLoad {
    [super viewDidLoad];


- (void)viewDidLoad {
     [super viewDidLoad];
     [super viewDidLoad];
   
     //Getting the optPut URL from eventTracker
     //Setting background image
     [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL
     UIImage *backgroundImage = [UIImage imageNamed:@"new_ios_bg.png"];
URLWithString:self.nielsenApi.optOutURL]]];
    UIImageView *backgroundImageView=[[UIImageView alloc]initWithFrame:self.view.frame];
}}
    backgroundImageView.image=backgroundImage;
    [self.view insertSubview:backgroundImageView atIndex:0];


    self.nielsenApi = [NielsenInit createNielsenAppApiWithDelegate:nil];


    //Initialising the webview
</syntaxhighlight>
    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
    _wkwebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
    _wkwebView.navigationDelegate = self;


    //Getting the optPut URL from SDK
=== Global iOS SDK No Ad Framework Opt-out ===
    NSURL *nsurl=[NSURL URLWithString:[self.nielsenApi optOutURL]];
The ''User Choice'' method can be used without the Ad Framework, or in situations where the publisher does not wish to use the [https://developer.apple.com/documentation/apptrackingtransparency App Tracking Transparency Framework]. As this flavor of the Nielsen SDK does not use the Ad Framework, so it is necessary to display an Optout Page to the user and capture their selection.


    //Setting url request in webview
Similar to the Global iOS SDK Flavor, it is a requirement to display a WebView element whose loadUrl is set to the
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
value obtained from optOutURL. This is a special URL that indicates Opt-in, or Opt-out and close the WebView.  '''The steps are as follows:'''


    //Setting url request in webview
* Get the Nielsen opt-out URL via [[optOutURL]]
    [_wkwebView loadRequest:nsrequest];
* Display a WebView element whose loadUrl is set to the value obtained from [[optOutURL]]
 
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
      //Adding webview to the controller view
** Opt-out if the WebView URL = <code>nielsenappsdk://1</code>
    [self.view addSubview:_wkwebView];  
** Opt-in if the WebView URL = <code>nielsenappsdk://0</code>
}
* Pass the detected URL to the [[userOptOut]] function
** Example: <syntaxhighlight lang=swift>NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out</syntaxhighlight>


</syntaxhighlight>
==== Sample code for No Ad Framework Build ====
|Swift = <syntaxhighlight lang="swift">
===== Swift =====
<syntaxhighlight lang="swift">
import UIKit
import UIKit
import WebKit
import WebKit
Line 113: Line 100:


class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
      
     var nielsenApi : NielsenAppApi!
     var webView: WKWebView!
     var webView: WKWebView!
    var nielsenApi: NielsenAppApi!
 
   
     override func loadView() {
     override func loadView() {
         webView = WKWebView()
         webView = WKWebView()
Line 122: Line 108:
         view = webView
         view = webView
     }
     }
   
 
     override func viewDidLoad() {
     override func viewDidLoad() {
         super.viewDidLoad()
         super.viewDidLoad()
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: "new_ios_bg.png")!)
 
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)
       
         if let appApi = self.nielsenApi {
         if let appApi = self.nielsenApi {
             //Getting the optPut URL from SDK
             //Getting the optPut URL from SDK
Line 133: Line 117:
                 webView.load(URLRequest(url: url))
                 webView.load(URLRequest(url: url))
                 webView.allowsBackForwardNavigationGestures = true
                 webView.allowsBackForwardNavigationGestures = true
             }
             }}}
 
        func closeOptOutView() {
            self.dismiss(animated: true, completion: nil)
         }
         }
    }
 
   
        func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler:
@escaping (WKNavigationActionPolicy) -> Void) {
            print(navigationAction.request.url?.absoluteString as Any) //For debugging to check what is being passed from webpage.
            if navigationAction.request.url?.absoluteString == "nielsen://close" {
                closeOptOutView()
                decisionHandler(.cancel)
            } else {
                if let url = navigationAction.request.url?.absoluteString, url.hasPrefix("nielsen") {
                    nielsenApi?.userOptOut(url). //either nielsenappsdk://1 or nielsenappsdk://0
                    decisionHandler(.cancel)
                } else {
                    if navigationAction.navigationType == .linkActivated {
                        if let url = navigationAction.request.url?.absoluteString, url.hasSuffix("#") {
                            decisionHandler(.allow)
                        } else {
                            decisionHandler(.cancel)
                            webView.load(navigationAction.request)
                        }
                    } else {
                        decisionHandler(.allow)
                    }}}}
 
}
}
</syntaxhighlight>
</syntaxhighlight>
}}
<br>


=== App Level Opt Out ===
===== Objective-C =====
This is only used if the Ad Framework is not available. The Opt-Out occurs by opening a Nielsen-defined web page and passing the user choice from the 'WebView'. In order to do this, the application needs to:
  <syntaxhighlight lang="objective-c">
* Implement the UIWebView delegate method to open the Nielsen Privacy web page
 
* Capture user's selection
#import "OptOutVC.h"
* Pass the selection back to the SDK via the <code>userOptOut</code>.
#import "NielsenInit.h"
#import <NielsenAppApi/NielsenAppApi.h>
 
@interface OptOutVC ()
 
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end
 
@implementation OptOutVC
 
- (void)viewDidLoad {
    [super viewDidLoad];


==== Capture and forward user selection ====
- (void)viewDidLoad {
{{ExampleCode|
    [super viewDidLoad];
|Objective C = <syntaxhighlight lang="objective-c">
    //Getting the optPut URL from eventTracker
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:self.nielsenApi.optOutURL]]];
}
   
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
{
     NSString *command = [NSString stringWithFormat:@"%@",request.URL];
     if ([navigationAction.request.URL.absoluteString isEqualToString:kNielsenWebClose])
    if ([command isEqualToString:kNielsenWebClose]) {
    {   [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];
        // Close the WebView
         decisionHandler(WKNavigationActionPolicyCancel);  
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];
    } else {
         return NO;
        if ([navigationAction.request.URL.absoluteString hasPrefix:@"nielsen"])
    }
        {[self.nielsenAppApi userOptOut:navigationAction.request.URL.absoluteString];
    // Retrieve next URL if it’s not opt-in/out selection
            decisionHandler(WKNavigationActionPolicyCancel);  
    return (![nAppApiObject userOptOut:command]);
        } else {
}</syntaxhighlight>
            if (navigationAction.navigationType == WKNavigationTypeLinkActivated)
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes <code>userOptOut</code> with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.
            { if ([navigationAction.request.URL.absoluteString hasSuffix:@"#"])
**<code>[nAppApiObject userOptOut:command]</code> passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.
                      {decisionHandler(WKNavigationActionPolicyAllow);
<blockquote>'''Note:''' When 'WebView' is closed, pass the status returned from 'WebView' to the SDK within the app. The App SDK manages the user's choice (Opt-Out / Opt-In), the app does not need to manage this status.</blockquote>
                } else {
|Swift = <syntaxhighlight lang="swift">
                    decisionHandler(WKNavigationActionPolicyCancel);
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
                    [webView loadRequest:[NSURLRequest requestWithURL:navigationAction.request.URL]];
                }} else {
                decisionHandler(WKNavigationActionPolicyAllow);
            }}}
}


        let command = request.url?.absoluteString
</syntaxhighlight>
        if  command ==  "kNielsenWebClose"{


            self.perform(#selector(closeOptOutView), with: nil, afterDelay: 0)


            return false
=== Global iOS SDK No ID Opt-out ===
        }   
If you are building an app that will be listed in the Kids Category:
        return NielsenAppApi.optOutURL
#  Ensure that you are using the [https://nielsendownloads-green.digitalengsdk.com/digital/Nielsen-iOS-App-SDK-GlobalNoId_latest.zip NoID version] of the Nielsen SDK Framework.
    }
#  Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:
<syntaxhighlight lang=swift>NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out</syntaxhighlight>


== Retrieve current Opt-Out preference ==
Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the [[optOutStatus]] property in the Nielsen SDK API
<syntaxhighlight lang="objective-c">
@property (readonly) BOOL optOutStatus
</syntaxhighlight>
</syntaxhighlight>
*The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes <code>userOptOut</code> with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.
**<code>[nAppApiObject userOptOut:command]</code> passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.
<blockquote>'''Note:''' When 'WebView' is closed, pass the status returned from 'WebView' to the SDK within the app. The App SDK manages the user's choice (Opt-Out / Opt-In), the app does not need to manage this status.</blockquote>
}}

Latest revision as of 18:24, 4 April 2023

Privacy and Opt-Out

There are currently 3 flavors of the Nielsen SDK. Please check the "Implementation" section for a comparison of the three flavors. Implementing opt-out for the three flavors are different:

  1. Global iOS SDK Opt-out - managed by AppTracking or Limit Ad Tracking setting on device.
  2. Global iOS SDK No Ad Framework Opt-out - Direct call to SDK. Can be used without the Ad Framework.
  3. Global iOS SDK No ID Opt-out - Direct call to SDK. Should be used for Kids Category.

Global iOS SDK Opt-out

OS-level Opt-out method available on Nielsen iOS

The Nielsen SDK automatically leverages the iOS's Limit Ad Tracking or AppTracking setting.

  • If the User's device is running < iOS 13.x, the Nielsen SDK will check the status of Limit Ad Tracking.
  • iOS14 modifies the way Apple manages the collection of a User's Opt-In status through AppTracking. Starting with Version 8.x+, the Nielsen App SDK will check the iOS version during initialization. If the device is running iOS12 or iOS13, the Limit Ad Tracking setting is requested. If iOS14.x +, then AppTracking is utilized.

Webview Element

It is a requirement to display a WebView element whose loadUrl is set to the value obtained from optOutURL. If using the Global iOS SDK, this optOutURL informs the user how to deactivate/activate “App Tracking/Limit Ad Tracking”.


If you are implementing on AppleTV here are your Opt Out verbiage options : https://engineeringportal.nielsen.com/docs/DCR_Video_%26_Static_CTV_Device_SDK_Privacy

Sample Code for Global Build

Swift
import UIKit
import WebKit
import NielsenAppApi

class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
    var nielsenApi : NielsenAppApi!
    var webView: WKWebView!
   
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()

    if let appApi = self.nielsenApi {
            //Getting the optPut URL from SDK
            if let url = URL(string: appApi.optOutURL) {
                webView.load(URLRequest(url: url))
                webView.allowsBackForwardNavigationGestures = true
            }}}

        func closeOptOutView() {
            self.dismiss(animated: true, completion: nil)
        }}
Objective-C
#import "OptOutVC.h"
#import "NielsenInit.h"
#import <NielsenAppApi/NielsenAppApi.h>

@interface OptOutVC ()

@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end

@implementation OptOutVC

- (void)viewDidLoad {
    [super viewDidLoad];

- (void)viewDidLoad {
    [super viewDidLoad];
    //Getting the optPut URL from eventTracker
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL
 URLWithString:self.nielsenApi.optOutURL]]];
}}

Global iOS SDK No Ad Framework Opt-out

The User Choice method can be used without the Ad Framework, or in situations where the publisher does not wish to use the App Tracking Transparency Framework. As this flavor of the Nielsen SDK does not use the Ad Framework, so it is necessary to display an Optout Page to the user and capture their selection.

Similar to the Global iOS SDK Flavor, it is a requirement to display a WebView element whose loadUrl is set to the value obtained from optOutURL. This is a special URL that indicates Opt-in, or Opt-out and close the WebView. The steps are as follows:

  • Get the Nielsen opt-out URL via optOutURL
  • Display a WebView element whose loadUrl is set to the value obtained from optOutURL
  • Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
    • Opt-out if the WebView URL = nielsenappsdk://1
    • Opt-in if the WebView URL = nielsenappsdk://0
  • Pass the detected URL to the userOptOut function
    • Example:
      NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out
      

Sample code for No Ad Framework Build

Swift
import UIKit
import WebKit
import NielsenAppApi

class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
    var nielsenApi : NielsenAppApi!
    var webView: WKWebView!
   
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        if let appApi = self.nielsenApi {
            //Getting the optPut URL from SDK
            if let url = URL(string: appApi.optOutURL) {
                webView.load(URLRequest(url: url))
                webView.allowsBackForwardNavigationGestures = true
            }}}

        func closeOptOutView() {
            self.dismiss(animated: true, completion: nil)
        }

        func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: 
@escaping (WKNavigationActionPolicy) -> Void) {
            print(navigationAction.request.url?.absoluteString as Any) //For debugging to check what is being passed from webpage.
            if navigationAction.request.url?.absoluteString == "nielsen://close" {
                closeOptOutView()
                decisionHandler(.cancel)
            } else {
                if let url = navigationAction.request.url?.absoluteString, url.hasPrefix("nielsen") {
                    nielsenApi?.userOptOut(url). //either nielsenappsdk://1 or nielsenappsdk://0
                    decisionHandler(.cancel)
                } else {
                    if navigationAction.navigationType == .linkActivated {
                        if let url = navigationAction.request.url?.absoluteString, url.hasSuffix("#") {
                            decisionHandler(.allow)
                        } else {
                            decisionHandler(.cancel)
                            webView.load(navigationAction.request)
                        }
                    } else {
                        decisionHandler(.allow)
                    }}}}

}
Objective-C
#import "OptOutVC.h"
#import "NielsenInit.h"
#import <NielsenAppApi/NielsenAppApi.h>

@interface OptOutVC ()

@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end

@implementation OptOutVC

- (void)viewDidLoad {
    [super viewDidLoad];

- (void)viewDidLoad {
    [super viewDidLoad];
    //Getting the optPut URL from eventTracker
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL
 URLWithString:self.nielsenApi.optOutURL]]];
}
     
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
 decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    if ([navigationAction.request.URL.absoluteString isEqualToString:kNielsenWebClose])
    {   [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];
        decisionHandler(WKNavigationActionPolicyCancel); 
     } else {
        if ([navigationAction.request.URL.absoluteString hasPrefix:@"nielsen"])
        {[self.nielsenAppApi userOptOut:navigationAction.request.URL.absoluteString];
            decisionHandler(WKNavigationActionPolicyCancel); 
        } else {
            if (navigationAction.navigationType == WKNavigationTypeLinkActivated) 
            { if ([navigationAction.request.URL.absoluteString hasSuffix:@"#"]) 
                      {decisionHandler(WKNavigationActionPolicyAllow);
                } else {
                    decisionHandler(WKNavigationActionPolicyCancel);
                    [webView loadRequest:[NSURLRequest requestWithURL:navigationAction.request.URL]];
                }} else {
                 decisionHandler(WKNavigationActionPolicyAllow);
            }}}
}


Global iOS SDK No ID Opt-out

If you are building an app that will be listed in the Kids Category:

  1. Ensure that you are using the NoID version of the Nielsen SDK Framework.
  2. Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:
NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out

Retrieve current Opt-Out preference

Whether the user is opted out via OS-level Opt-out or via User Choice Opt-out, the current Opt-Out status as detected by the SDK is available via the optOutStatus property in the Nielsen SDK API

@property (readonly) BOOL optOutStatus