         }
     }
     
+    // MARK: - Background Sessions
+    public func setBackgroundSessionCompletionHandler(completionHandler: () -> Void, sessionIdentifier: String) {
+        if session.configuration.identifier == sessionIdentifier {
+            backgroundSessionCompletionHandler = completionHandler
+        }
+    }
+    
     // MARK: - Request tracking
     func registerRequest(request: Request) {
         registeredRequests[request.tag] = request

    }
    
    private var registeredRequests = [String: Request]()
    
    lazy var session : NSURLSession = {
        let sessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(NSBundle.mainBundle().bundleIdentifier!)

    
    func unregisterRequest(request: Request) {
        registeredRequests[request.tag] = nil
    }
    
    // MARK: - NSURLSessionDelegate
    public func URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession) {
        backgroundSessionCompletionHandler?()
        backgroundSessionCompletionHandler = nil
    }
    
    // MARK: - NSURLSessionDataDelegate
