You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This class helps coordinate communications between the paired iPhone and Apple Watch, for this communication to take place, we need to instantiate the WCSession classes in both the iPhone and Watch controllers
Initially, I'll research into the best way to tackle the transference of data using Watchkit Connectivity. I've found 4 ways to tackle this. I'll be methods and the pros/cons of using each below
updateApplicationContext - sends a small amount of information, this information should be used to update interface. ( warningeach successive updateApplicationContext call replaces the data sent by the previous call )
transferUserInfo(_:) - sends the specified data dictionary to the paired device ( this content of the dictionary must not be nil.
This method should be called when you want to transfer dictionary of data. This method seems to be synchronous as each call is queued up and delivered one after another.
This transfer continues even if the app is suspended This is cool!
Another Method linked to this is called transferCurrentComplicationUserInfo(_:) - This method sends complication data from the iPhone to the Watch (Unidirectional) [Important note Only transfer complication data]
Files are transferred asynchronously on a background thread. If the file cannot be sent, then it calls the session:fileTransfer:didFinishWithError: to report the error.
Important This method can only be called when the session is active. If it is called when the session is inactive/deactivated then it returns an error.
Messages are queued and received on the other device in the order they were sent. (messages are sent asynchronously, so the method returns immediately)
sends a dictionary, optional replyHandler will receive a response if present, ErrorHandler for handling errors!
Important This method can only be called when the session is active. If it is called when the session is inactive/deactivated then it returns an error.
From The API Reference Documentation
Calling this method from your WatchKit extension while it is active and running wakes up the corresponding iOS app in the background and makes it reachable. Calling this method from your iOS app does not wake up the corresponding WatchKit extension. If you call this method and the counterpart is unreachable (or becomes unreachable before the message is delivered), the errorHandler block is executed with an appropriate error. The errorHandler block may also be called if the message parameter contains non property list data types.
The text was updated successfully, but these errors were encountered:
I've managed to get transferUserInfo to work using the following.
Phone
Here I've created a session as well as a method that transfers information to the watch -> transferUserInfo, I then run the method when the phone view loads.
Watch
In the watch controller, we've added a method didReceiveUserInfo which receives the information.
Issues
As you can see I've managed to get the dictionary across to the phone.
But in it's current form, I am unable to access each individual item in the array.
Issues
So the next steps for me:
Figure out the best way to extract the array of tasks
Display the individual tasks on the watch in a list?
Now that a user has the ability to add/edit/delete tasks on the iPhone, The next step is to show these tasks on the Apple Watch. (#21)
WatchKit Connectivity Framework
WCSession Class
Initially, I'll research into the best way to tackle the transference of data using Watchkit Connectivity. I've found 4 ways to tackle this. I'll be methods and the pros/cons of using each below
updateApplicationContext
call replaces the data sent by the previous call )transferCurrentComplicationUserInfo(_:)
- This method sends complication data from the iPhone to the Watch (Unidirectional) [Important note Only transfer complication data]session:fileTransfer:didFinishWithError:
to report the error.The text was updated successfully, but these errors were encountered: