3
votes

I am developing an iPhone app on Xamarin and have added an Apple Watch extension for watchOS 3.

I need to get data that is save on the iPhone to the watch extension.

I only need to get it once, and then save it on the watch so it can be used without the iPhone's presence. How can I do this?

EDIT

Solved by using Iain Smith's WCSessionManager class

1

1 Answers

5
votes

Depending on the data you could use update Application Context messages. In brief, application context is best used for transferring data that always needs to be updated to the latest information. This is important because, for all of the data that you’re transferring over, only the latest copy of that data will actually appear at your final destination.

Have a look at this sample once you get the message then you could save it in NSUserDefault or whatever suits.

It is written for watchOS 2.0+

WCSessionManager is class that handles the delegate calls have a look here

It is basically a singleton that helps manage the connection, so you dont have to put it in all your interface conteroller or viewcontrollers.

Its starts in ExtensionDelegate on the watch and in ApplicationDelegate on the phone.