Is it possible to implement custom UDP protocol on iOS with xcode network extensions?

Hi.


I have voip iOS application and it uses UDP sockets. Earlier I used voip background feature for periodic monitor UDP sockets in background mode, approx every 10 min timeout. But today voip background feature is deprecated. I know about xcode network extensions, but I am not sure exactly what it means. I need rx/tx UDP datagrams in the background mode. May be I can implement custom UDP protocol for working in background mode (with the help of xcode network extensions)?


Thanks!

Earlier I used voip background feature for periodic monitor UDP sockets in background mode …

And how exactly did you do that? The legacy VoIP architecture was only supported for TCP connections.

Share and Enjoy

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

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

It was not fully support voip service, I used setKeepAliveTimeout for my goals. My app is just a local chat with file transfer feature and voice calls.

Accepted Answer

I used

-setKeepAliveTimeout:
for my goals.

Right, but one of the key features of the legacy VoIP architecture is that it could resume your app in the background when data arrives on your VoIP control connection. This connection had to be TCP because the APIs to enable VoIP mode (like

NSStreamNetworkServiceTypeVoIP
) only supported TCP.

Anyway, it sounds like your real requirement is “How do I get resumed in the background every 10 minutes?” in which case the answer is “You can’t.” This facility was a bit of a kludge — kinda like the rest of the legacy VoIP architecture — and there’s no direct replacement.

Coming back to your earlier questions, you wrote:

I need rx/tx UDP datagrams in the background mode.

It’s perfectly possible to do UDP networking in the background. There are two gotchas I’m aware of:

  • Things work as expected as long as your app doesn’t get suspended. Once your app gets suspended things get complex. Technote 2277 Networking and Multitasking has the details on this.

  • In most cases a WWAN-capable device will disassociate from Wi-Fi shortly after screen lock. If your UDP code is expecting to be on the local Wi-Fi, you’re going to be disappointed.

May be I can implement custom UDP protocol for working in background mode (with the help of xcode network extensions)?

Nothing in Network Extension framework will help you with this.

I generally push (hey hey) folks towards push notifications for this sort of thing. Is there a reason that’s not feasible in your case?

Share and Enjoy

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

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

Thank you so much for extended answer!


Yes, I know about TCP and NSStreamNetworkServiceTypeVoIP. We can introduce TCP socket for legacy support VoIP service but it is late (As far as I know this VoIP arch is not supported after iOS 10).

Now our UDP peer-to-peer system/protocol:

- System performs in local area network only (WiFi).

- UDP broadcast socket for discovery new peers in local area network (WiFi).

- UDP unicast socket for transfer data between discovered peers.

- All peers from one WiFi network are connected to each other.

- We have no problems between background/foreground switching. We reopen all UDP sockets. It is simple, cheap, and has no user visible consequences.


Of course we want to work in background mode and stay connection between all peers in current WiFi network, this needs for notify about new incoming messages, files and voice calls. This solution have 2 main advantage points:

1. Low cost. No need in servers.

2. No need internet connection, just WiFi network.


We also know about Apple battery optimization and PushKit and it is very important part of iOS device. We have very good testing results of our system: CPU efficient, memory usage and energy consumption. We hope in the future Apple will introduce some network service app extension for these goals (implementation user defined protocol as a some service process). May be Apple will implement PushKit extension for local area network only, or something else. As a result we will have new more interesting apps in the App Store.


Thanks!

Is it possible to implement custom UDP protocol on iOS with xcode network extensions?
 
 
Q