问题
I am experiencing a difficulty with background socket connections under iOS 13. I have been using UIApplication.shared.beginBackgroundTask{ ... }
to make sure my socket connection survives app's transitioning to background[1]. Up to iOS 12 this gave me a few minutes of background activity, which worked just fine. As of iOS 13 this is no longer the case. Under iOS 13 the old API gives me only a 30-second background task, while I need up to 2 minutes of uninterrupted socket connectivity. I have taken a look at the new APIs (there's a WWDC19 talk), but it seems nothing suits my needs. The new APIs are executed at a system-friendly time and duration.
[1] It is required by the business case that I establish a socket connection and then the user switches to another app of which I have no control of (it can be almost any app).
来源:https://stackoverflow.com/questions/59718332/can-i-retain-a-socket-connection-in-the-background-for-longer-than-30-seconds