Network Socket Background Task

Hello everyone,

I have developed an app that is a local networking monitor app for a specific building automation protocol.

I have searched the forum and I think I have found some older posts regarding this topic but I could not figure out if my issue falls under the same category.

So my app allows the user to connect to local protocol devices, and start a monitor session where they can see incoming/outgoing packets. The connections are UDP or TCP and require opening a socket.

Currently, backgrounding the app will make the OS terminate the socket connection, therefore ending the monitor, even if the app is backgrounded by user, to let's say, perform some other task in their phone.

I have several requests from users to improve the app by allowing the monitor to continue while the app is backgrounded. However, by reading the relevant documents, I have found this to be almost impossible in iOS app. I have considered:

  • Remote Push Notifications (APNs): The app operates on LAN so this is not an option, since I do not have an infrastructure to somehow send notifications to keep app process alive.

  • Background Tasks (BGTaskScheduler): Not my case, since I do not want periodic execution. The app requires continuous socket listening.

  • VoIP, VPN, or Audio Background Modes: My app does not fall under any of these categories, even though this would solve my situation.

By searching around a bit more, I might be able to use either BGProcessingTask, which would allow my app at least to run for some minutes and show the user that they have to foreground it in order to not stop the monitor process, or maybe even App Intents framework.

Has anyone faced similar requirement for their app? Any tip or point to a direction I should investigate more?

Thanks,

Nikos

Answered by DTS Engineer in 894228022
I have found this to be almost impossible in iOS app.

Indeed. Lemme start you out with iOS Background Execution Limits, after which you can reply back here with any follow-up questions you have.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer
I have found this to be almost impossible in iOS app.

Indeed. Lemme start you out with iOS Background Execution Limits, after which you can reply back here with any follow-up questions you have.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits.

BGProcessingTaskRequest is unlikely to help here. Usually those fire in the middle of the night.

BGContinuedProcessingTask might work. You have to balance its utility against the resulting user experience.

The other option is a UIApplication background task, which has no user experience impact but only offers a small amount of runtime after moving to the background.

Is that acceptable in apple review with clear explanation?

I don’t work for App Review and thus can’t make definitive statements about their policy.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks again for your time and support.

I will explore those options and try to make the best out of them.

Network Socket Background Task
 
 
Q