Reputation: 1061
Let's brainstorm. I have a messenger-like app. When I send a message to a chat, there are many network request being sent, a lot of UI is redrawn and a lot of print
logging performed. This might take 5-10 seconds to complete, with Xcode console bursting with print
s.
When I send a message and tap a Home button on a simulator or a device, app is backgrounded, applicationWillResignActive
and applicationDidEnterBackground
are called, but the app seems to be more than alive and happily sends the requests and parses the responses, probably redraws UI, and prints, prints and prints.
Why might this happen? Is there a general knowledge of preventing app from backgrounding, that I have overlooked?
There are no background modes in the app, no code in question is wrapped in BackgroundTasks, nothing. Just listening to Starscream
socket, sending requests through Alamofire
, and updating tableview in UIKit
.
Any of your suggestions are appreciated.
Upvotes: -1
Views: 78
Reputation: 1061
Mystery solved. Turns out, that UIApplication.shared.beginBackgroundTask
, no matter where and by whom was called, just asks app not to die for the next 30 seconds or so.
And while app is not dead (suspended), ANY unrelated code in your app is free to run.
In my case, there were several cocoapods, which called UIApplication.shared.beginBackgroundTask
for their own needs. And while app was still running, some of my code was more than happy to run along.
Upvotes: 0