Watch Connectivity - how to handle existing todo app?

Hi, it’s first topic in watchOS forum! :smiley: I should be rewarded :wink:

Back to the question. I have existing todo app on my iPhone. Now I want to create watchOS 2 app to extend it.
I want to allow user to check or uncheck today tasks.
I need to connect everyday with iPhone to get task for every single day, how to handle it?

I have watched WWDC videos about WC and I have read watchOS 2 by Tutorials.

Should I send Interactive Message from Watch to iPhone, and iPhone should get tasks from coredata and send them back to Watch as Dictionary ? Is it good approach?

Every time when iPhone change something (delete task, add new to today tasks list, edit name or something) I send ApplicationContext with all Tasks, but sometimes it has a problem with connection. Do I’m doing it right?

Hi, it’s first topic in watchOS forum! :smiley: I should be rewarded :wink:
Back to the question. I have existing todo app on my iPhone. Now I want to create watchOS 2 app to extend it starbuckssecretmenu
I want to allow user to check or uncheck today tasks.
I need to connect everyday with iPhone to get task for every single day, how to handle it?
I have watched WWDC videos about WC and I have read watchOS 2 by Tutorials.
Should I send Interactive Message from Watch to iPhone, and iPhone should get tasks from coredata and send them back to Watch as Dictionary ? Is it good approach?
Every time when iPhone change something (delete task, add new to today tasks list, edit name or something) I send ApplicationContext with all Tasks, but sometimes it has a problem with connection. Do I’m doing it right?

It sounds like you’re on the right track with your watchOS app! Your approach to using interactive messages and application context is valid, but there are some best practices to ensure a smooth user experience.

Communication Strategy

  1. Interactive Messaging:
  • Yes, using WCSession to send interactive messages from your watch app to your iPhone app is a good way to request the current tasks for the day. This allows your watch app to be responsive to user actions, like checking or unchecking tasks.
  1. Application Context:
  • Sending the application context when there are changes on the iPhone (like adding, deleting, or editing tasks) is a solid approach. However, you might want to handle cases where the connection is not available. Use WCSession’s sendMessage(_:replyHandler:errorHandler:) for immediate requests and consider sendMessageData(_:replyHandler:errorHandler:) for larger data if necessary.

Handling Connection Issues

  • Fallback Mechanism: Implement a fallback mechanism. If the sendMessage fails due to connectivity issues, you could store the request and try to resend it later, or handle it in a way that informs the user about the connectivity issue.
  • Data Synchronization: Consider using a background transfer approach where the iPhone app periodically syncs tasks with the watch app. You can schedule background updates to ensure that the watch app always has the latest data available, even when the connection is intermittent.

Performance Considerations

  • Data Size: Be mindful of the amount of data being sent back and forth. If the tasks list grows, consider sending only changes (deltas) rather than the entire list.
  • State Management: Ensure that the watch app maintains a local cache of tasks to minimize the need for constant communication with the iPhone. Update this cache when the app receives new data from the iPhone.