UDP communication in background

Hi,


Our app is a heart rate monitoring app. The device communicates with app using UDP protocol. For our app, the background communication is essential too. Since Apple does not support UDP communication in background, how can achieve the same?

You'll have an easier time changing your hardware to BTLE than you will trying to get background UDP networking.

I tried playing an audio in the background. The UDP communication was working when in background as expected. Should I try that way? But heard, the chances of app rejection is high.

Since Apple does not support UDP communication in background …

This isn’t quite right. Networking, including UDP, works in the background just fine as long as you prevent your app from being suspended (see Technote 2277 Networking and Multitasking for the details). There’s no general-purpose mechanism to prevent an app from being suspended while in the background. There are a bunch of special-purpose mechanisms — you’ve already discovered the

audio
background mode — but their use is strictly monitored by App Review per clause 2.5.4 of the App Store Review Guidelines.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo,


Thanks for your detailed perfect answer. I have one more doubt.

Our functionality is :- The external device(patch) and the iPad should be in same Wifi. The app listens via UDP for getting list of these devices around. The app then connects to the required patch via UDP. Can I use the Wireless External Accessory framework for making it work in the background? If yes, then how can I define the protocol of communication?

Accepted Answer

Can I use the Wireless External Accessory framework for making it work in the background?

Last I checked External Accessory framework supports USB and (classic) Bluetooth, but not Wi-Fi. However, my knowledge could be out of date here. These accessories go through MFi and other folks in DTS support MFi stuff.

Regardless, I doubt you’ll be able to make headway here because of the iOS Wi-Fi lifecycle. For devices with a working WWAN iOS will typically disassociate from the Wi-Fi shortly after screen lock (this helps to save power). When that happens critical system services are expected to transition to running over WWAN (alternatively, they might always run over WWAN, like push notifications). It stands to reason that, if the device has left the Wi-Fi, no traffic on the Wi-Fi can wake it up.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
UDP communication in background
 
 
Q