0

Background info
I'm writing a cross-platform App that can send updates to linked devices. These updates are based on time.

During testing I've noticed that devices (mobile phones, watches or TV's) using the iOS or Android platform can have a very small difference in the time they're using on each device. Worst case I've seen is a difference of around 10 secondes. They're apparently not all using the same source for setting the time on each device..

My App relies on the fact that the time on each linked device is exactly the same. The issue described above results in strange behavior of my App and I want to make sure that everyone is looking at the same thing.

Possible solution
The solution I came up with is retrieving the time from the same NTP server for the various devices of the two platforms. This way I can determine per device the offset and display the correct time.

I'm also considering creating an API call to my own server, but this is something I'm trying to avoid considering possible performance issues of my server that could result in incorrect times.

Problem
The problem however is that I've found libraries / code for Android that works on mobile phones, watches and TV's and I've found code that works for iOS on mobile phones, nothing I've found seems to work for watchOS (8 or above) on Apple Watch.

Reading this (https://github.com/tdlib/td/issues/1442) article it seems that Apple has closed the door on network sockets. I've tried this (https://github.com/ncvitak/NTPKit) library that works on iOS, but on watchOS it returns "No route to host". This is what the article also mentions. Other NTP libraries or code examples I've found don't seem to work on watchOS.

Question
Is it possible, without the support of a mobile phone, to retrieve the time from a NTP server of my chosing using SwiftUI for watchOS (8 or above) directly from the Apple Watch?

Many thanks.

Bash
  • 125
  • 6

0 Answers0