Networking Delegation

This page explains how to configure the behavior of NSURLSession using the Bazaarvoice Mobile SDK for iOS.

Introduction

The iOS SDK uses NSURLSession for issuing networking requests, therefore, if you're attempting to configure the behavior of the NSURLSession or would like to control how various tasks are handled then using the BVURLSessionDelegate is the way to do that. After you have created an object that implements the BVURLSessionDelegate protocol you can set it into action by following the example below:

Example

In the code below, after this delegate is set, it will dispatch your object's implemented methods appropriately for every pertinent networking request that the Bazaarvoice iOS SDK issues on your behalf. Please see the documentation and comments in the module for more specific information pertaining to behavior.

let urlSessionDelegate: BVURLSessionDelegate = ... /// acquire your delegate
 
/// and set the delegate on the BVSDKManager.
BVSDKManager.shared().urlSessionDelegate = urlSessionDelegate
id <BVURLSessionDelegate> urlSessionDelegate = ... /// acquire your delegate
 
/// and set the delegate on the BVSDKManager.
[BVSDKManager sharedManager].urlSessionDelegate = urlSessionDelegate;
let urlSession: URLSession = ... /// acquire your urlSession
BVManager.sharedManager.urlSession = urlSession

πŸ“˜

Even though the setting of this delegate is thread safe there is no guarentee for it to be atomic with respect to any enqueued networking requests, responses, etc. therefore, we recommend to only set this delegate early in your application's launch (at initialization time) for the best results.