0

I am using Alamofire for my uploads. I need to upload multiple images and videos to my server.I need to upload images and videos to in background session even

    let bundleIdentifier = Bundle.main.bundleIdentifier
            let configuration = URLSessionConfiguration.background(withIdentifier: bundleIdentifier!)
            configuration.timeoutIntervalForRequest = 200 // seconds
            configuration.timeoutIntervalForResource = 200
            self.alamoFireManager = Alamofire.SessionManager(configuration: configuration)

I am using above code setup alamofire for background configuration.
            alamoFireManager?.upload(data!, with: (router))
                .uploadProgress { progress in // main queue by default
                    print("Upload Progress: \(progress.fractionCompleted)")
                }.validate()
                .responseJSON { [weak self] response in
}

but my app is crash when i went to background with SIGABRT

let me know what i am doing wrong,

AppleBee
  • 452
  • 3
  • 16

1 Answers1

0

This is a limitation of Apple's NSUrlSession implementation. Apple doesn't allow usage of NSData for background sessions. But uploading files are allowed. So as a workaround, you can try writing the data to a file and upload that file instead. You can follow the implementation here:

https://stackoverflow.com/a/22107789/1921759

naydin
  • 345
  • 4
  • 5