0

I want to post a json using URLSession when the connection is active. For that, I'm using URLSessionConfigurationand setting configuration.waitsForConnectivity = true and it works fine. my problem is when the App goes to background before the performing the Post and even the connectivity is available nothing happens ! so I changed URLSessionConfiguration to use background mode:

 let configuration = URLSessionConfiguration.background(withIdentifier: BackgroundSession.identifier)
configuration.waitsForConnectivity = true 

but same problem :/ Is there any way to start the Post even the App is in background mode.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    is not possible to tell what the problem could be with the provided information but, notice that for a background session `waitsForConnectivity` is ignored. https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/2908812-waitsforconnectivity?language=objc – Andrespch Aug 14 '19 at 09:46
  • Did you enable background fetch? Go to project target -> Capabilities -> enable Background Modes -> check Background Fetch – Vadim F. Feb 18 '19 at 09:47

0 Answers0