Difference between revisions of "iOS NoID Privacy and Opt-Out"
From Engineering Client Portal
ColinBrown (talk | contribs) (→Privacy and Opt-Out) |
ColinBrown (talk | contribs) (→Retrieve current Opt-Out preference) |
||
Line 11: | Line 11: | ||
<syntaxhighlight lang="objective-c"> | <syntaxhighlight lang="objective-c"> | ||
@property (readonly) BOOL optOutStatus | @property (readonly) BOOL optOutStatus | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == Display OptOut Notice == | ||
+ | Nielsen does not use cookies in measurement in Ireland; however, you may want to present this information to your user. Sample code on how to do this is below: | ||
+ | |||
+ | ==== Sample Code for Global Build ==== | ||
+ | ===== Swift ===== | ||
+ | <syntaxhighlight lang="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) | ||
+ | }} | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===== Objective-C ===== | ||
+ | <syntaxhighlight lang="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]]]; | ||
+ | }} | ||
+ | |||
+ | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 01:49, 14 June 2022
Contents
Privacy and Opt-Out
The Irish Market build of the Nielsen SDK automatically Opt's Users out of the collection of any User Identifiable information or any Device Advertising ID.
When building your app:
- Ensure that you are using the 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:
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
Display OptOut Notice
Nielsen does not use cookies in measurement in Ireland; however, you may want to present this information to your user. Sample code on how to do this is below:
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]]];
}}