             return
         }
     }
+
+    public func URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession) {
+        session.getTasksWithCompletionHandler { (dataTasks, uploadTasks, downloadTasks) -> Void in
+
+            if downloadTasks.count == 0 {
+                
+                if let completionHandler = self.backgroundTransferCompletionHandler {
+
+                    NSOperationQueue.mainQueue().addOperationWithBlock({
+                        [unowned self] in
+
+                        completionHandler()
+                        self.backgroundTransferCompletionHandler = nil
+                    })
+                }
+            }
+        }
+    }
 }


    // MARK: NSURLSessionDownloadDelegate

    func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) {
        println("Resume at offset: \(fileOffset) total expected: \(expectedTotalBytes)")
    }

    func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
        let download = self.downloads[downloadTask.taskIdentifier]!
        let progress = totalBytesExpectedToWrite == NSURLSessionTransferSizeUnknown ? -1 : Float(totalBytesWritten) / Float(totalBytesExpectedToWrite)


    public static let sharedInstance = TCBlobDownloadManager()

    /// Instance of the underlying class implementing `NSURLSessionDownloadDelegate`.
    public var delegate: DownloadDelegate

    /// If `true`, downloads will start immediatly after being created. `true` by default.
    public var startImmediatly = true

    /// The underlying `NSURLSession`.
    public var session: NSURLSession

    /**
        Custom `NSURLSessionConfiguration` init.
