Post

Replies

Boosts

Views

Activity

Please, eli5 me the flow to update AppleWatch complications in background, using data from iOS companion app
My god I feel so dumb. Please help. I have: an iOS app that displays calendar/reminders list (using EventKit data) a set of iOS widgets that also display these lists, but in a widget form the data fetch logic is shared, as well as most of the UI (everything's in SwiftUI) I'm trying to: create a WatchOS app and a a set of watch complications, to display calendars/reminders on the watch IMPORTANT: iOS app is the source of truth for all the data (it need to be post-processed after fetching from EventKit) Here's what works/flow fine (I understand how it works): iOS app updates its data upon launch (or EventKit update message). All good. iOS widgets update their data when iOS asks them to provide a new timeline. Widgets just reach out into EventKit directly on iPhone, and are done with everything (same device, enough processing power, direct access). All good. Watch app (as far as I understand), upon launch, would just need to send a request for data message to the iOS companion app, and iOS companion app would then just "push" the data back to the watch app (after post-processing it into a proper dictionary). So, I'm mostly good with it as well, I think. Watch app could update complications once it is launched and received data from iOS companion app (right?…) And here's where I'm stuck: I can't for the life of me to figure out what would be the flow to update Watch complications automatically in the background, using data from the iOS app's source of truth. I would assume it might be something like: watchOS requests a complication to provide its timeline (at whatever time it decides to do that - I can only be partially in control of the timing) complication, in turn, um…… calls the WatchOS app? (right?……) and requests the data required to build the timeline from the watch app once watch app receives that request from complication, it: sends request for data message to the companion iOS app receives the data from iOS app in a form of dictionary rebuilds the complication's timeline with the data it received from the iOS app Questions: Does the above flow sounds right at all? There does seem to be a lot of messages flowing around and between… Is it how it's supposed to be? What would be the very best approach to this situation? A simple flow outline would help immensely. I tried to look through the documentation and I'm feeling completely worn out… I can't connect the pieces and I just can't find the right place to start so I can untangle the logic (what starts when, request data from where, how) Any guidance is appreciated. I think I'm probably missing something very basic, but I have no idea what exactly :( Thanks! PS: I would like to support watchOS 8+, iOS 15+, so I guess newest additions to watchOS 9 are not applicable. I build everything in SwiftUI.
0
1
619
Aug ’22