I am creating a WatchKit app and was wondering how to send a message/data from the iPhone to the Watch?
I know how to do it the other way around (watch -> phone) using 'openParentApplication:reply:' and 'application:handleWatchKitExtensionRequest:reply:' but can't find any documentation on how to communicate from phone to watch.
Simple setup would be the iPhone app has a button that when pressed should update a label on the Watch app.
Can anyone point me in the right direction?
You should try App Groups which are what you use to share data between iOS apps and App Extensions.
In your Apple Watch app interface controller class:
In your parent app:
"AppShare" is the name you assign when you create an App Group in Capabilities for your parent app target.
Alternatively,
You can use this solution to share files even between 2 different apps and of course between watch app (Extension) and parent iOS app.
First step is described by @zisoft, enable app group.
Then get the URL of group container at runtime,
Now you can write any file/folder at the given path, Below is my example snippet,
watchOS 2.0 has a new framework which is called Watch Connectivity Framework that let you send messages between the two devices.
Please see the example here including the example of sending the actual dictionary using debug mode.
A WiKi example is also available.
Good luck.
It's work for me. Try use in watch
in main app
First, you have to enable app groups for your target:
Then you can start to write and read objects via
NSUserDefaults
:See the chapter Sharing Data with Your Containing iOS App in Apple Watch Programming Guide: Developing for Apple Watch