iOS SDK App Level Opt Out

From Engineering Client Portal

Revision as of 20:42, 4 December 2019 by ColinBrown (talk | contribs) (Created page with "{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|DCR & DTVR}} {{CurrentBreadcrumb}} Category:Digital === App Level Opt Out === This is only used if the Ad Framework is...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Engineering Portal / Digital / DCR & DTVR / iOS SDK App Level Opt Out

App Level Opt Out

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:

  • Implement the UIWebView delegate method to open the Nielsen Privacy web page
  • Capture user's selection
  • Pass the selection back to the SDK via the userOptOut.

Capture and forward user selection

Swift

 func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {

        let command = request.url?.absoluteString
        if  command ==  "kNielsenWebClose"{

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

            return false
        }    
        return NielsenAppApi.optOutURL
    }
  • The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes userOptOut with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.
    • [nAppApiObject userOptOut:command] passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.

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.

Objective C

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *command = [NSString stringWithFormat:@"%@",request.URL];
    if ([command isEqualToString:kNielsenWebClose]) {
        // Close the WebView
        [self performSelector:@selector(closeOptOutView) withObject:nil afterDelay:0];
        return NO;
    }
    // Retrieve next URL if it’s not opt-in/out selection
    return (![nAppApiObject userOptOut:command]);
}
  • The app gets the user selection string via webviews shouldStartLoadWithRequest and invokes userOptOut with user selection. The delegate method handles the 'WebView' URL requests, interprets the commands, and calls the SDK accordingly.
    • [nAppApiObject userOptOut:command] passes the user's selection on Nielsen Privacy page to the SDK to allow the SDK to perform the required functions.

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.