Background telemetry from a network device and display on iPhone and Watch

Hi,


I have an iOS and WatchOS application that receives telemetry from a hardware device over WiFi on a custom TCP Port.

I want to be able to display the information on the watch even if the iPhone app is in the background or suspended.

The data is streamed from the hardware device to the iPhone app so it's not something that can be fetched.

I would also be able to push notifications based on certain telemetry conditions being met.

As the data is purely local those notifications cannot be pushed from a server infrastructure.


Is there a run in background mode that I can use for this or how best should I approach this?


Thanks,


Sean.

Replies

First up, watchOS. There’s absolutely no way to achieve this goal on watchOS because watchOS does not let third-party code open TCP connections.

Secondly, terminology. I’m going to label your hardware device as an accessory, so I can continue using device to mean an iOS device.

Finally, to the meet your your issue. The basic rules for networking in the background are covered by Technote 2277 Networking and Multitasking. In short, networking works just fine in the background as long as your app doesn’t get suspended. Once suspension comes into the picture, stuff gets complex.

iOS has no general-purpose API for running indefinitely in the background. There’s a bunch of special purpose stuff that may or may not meet your needs. To offer any concrete advice I need to know more about your specific requirements. Can you explain more about what your accessory does. I’m specifically interested in the user experience you’re looking for.

Share and Enjoy

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

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

Hi Quinn,


Thanks for getting back to me. I appreciate the help.


My app currently communicates with a Navigation system on a sailboat.

While the app is running on the iPhone, if data that is displayed on the Watch changes, it sends it to the Watch.

Some useful items that are displayed on the Watch app are Current Depth, Current Speed over ground, Current Speed through the water and a visualization of the Apparent and True wind angles.

As you can imagine, this data needs to be up to date when the user uses the watch app as important decisions are made from this data.


The way the iOS app communicates with the Navigation unit is over sockets. When the data changes, the navigation unit sends the data to the iOS app.

It's not a web service or a URL that can be called.


Having looked at this further I quess I could register the app as a navigation app and use location to determine that the person is moving and will need the app to be running (would have a way for the user to select "start sailing" so that the app isn't tracking location all the time).


Thanks,


Sean.