Standard set up for Watch OS > 2.
WCSessionDelegate
used to coordinte data between main application and Watch.
An App Group "group.***********.TodayExtensionWidget"
used to coordinate data between main application and its Today Extension widget via UserDefaults(suiteName: "group.***********.TodayExtensionWidget")
When I make a change from the watch it communicates that change with the main application. Then the main application (once launched) communicates this on to the Today Extension. What I would like to do is communicate the change in the watch app to the Today extension without needing to launch the main app first.
Is there a best practice to communicate between a watch app and a Today Extension widget?
At the moment there is no way to achieve this using any built-in frameworks. Since the introduction of
watchOS2
,WatchKit
apps are considered to be independent apps and not just an extension of theiOS
app, hence you cannot useAppGroups
to share data between the two and especially cannot use it to share data between theWatchKit
app and aniOS
extension.As you already experienced,
WatchConnectivity
cannot be used in aToday extension
, so that is out of the picture as well.Your only option is a suboptimal one, since you will need to upload your data to a server from your
watchOS
app and download it in youriOS Today extension
. This of course generates unnecessary data usage, but with the current frameworks provided by Apple you cannot share the data offline.However, if you wait until
watchOS4
is released (or give the beta version a try), you might be able to leverage theCoreBluetooth
framework, which is becoming available forWatchKit
inwatchOS4
to communicate between aWatchKit
app and aniOS
extension offline, usingBLE
. I am not 100% sure ifCoreBluetooth
can be used iniOS Extensions
, but you should give this a try if you can usewatchOS4 beta
.