InterceptorManager

public class InterceptorManager : NSObject, InterceptorManagerProtocol

A class that handles some messages from the URLSession. It forwards them to the interceptors along with some other internal network client messages.

  • Initializes the interceptor manager with the provided interceptors and queue.

    Declaration

    Swift

    public required init(interceptors: [RequestInterceptor], queue: TealiumQueue)
  • Called when a URL session task is waiting for connectivity.

    Declaration

    Swift

    public func urlSession(_ session: URLSession, taskIsWaitingForConnectivity task: URLSessionTask)
  • Forward the the result of a network request to all the interceptors and perform the shouldRetry callback based on the RetryPolicyreturned by the interceptors.

    Retries are checked in reverse order as it’s assumed that the latest added RequestInterceptor is a more specific interceptor that has a finer logic compared to the default ones that are added in the beginning.

    Declaration

    Swift

    public func interceptResult(request: URLRequest, retryCount: Int, result: NetworkResult, shouldRetry: @escaping (Bool) -> Void)

    Parameters

    request

    the URLRequest that was just completed

    retryCount

    the number of times this request has been retried already (starts from 0)

    result

    the NetworkResult returned by the client

    shouldRetry

    the completion block, called when it’s time to retry with true or immediately with false if the request should not be retried.