My app makes some server calls whenever it is started, now I face a weird problem: when a push notification with content_available
wakes up my app the calls are made as well, but more often than not they run into a timeout.
Does this have to do with the app being in the background? Is something configured wrong? I activated background modes background fetch
as well as remote notifications
. Am I missing something?
Am I missing something?
It's very hard to know since you haven't shown any code, but it sounds like you're not setting up your network session with the configuration returned from URLSessionConfiguration's background(withIdentifier identifier: String)
method. You can't just fire off requests when your app is in the background the same way you would in the foreground; using the background configuration lets the system manage the transfer on your app's behalf.
You have to use NSUrlSession for connecting while in background. Make sure you use it instead of NSURLConnection or any other connectivity library that is not backed by the session. While in background your app can be suspended and re-activated many times and the session in the only facility that can properly handle this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With