Xamarin Apple Watch Extension - Consuming simple JSON Web Service

KingspodKingspod Member

I've built a simple Xamarin.forms app which connects to a web service and gets one piece of data and displays it.

I wanted to do the same on an apple watch (targetting a series 2 apple watch) but I just don't understand how it works.

I've added the watch project and the watch extension, created the interface... Got a "refresh" button which changes the value of the label to a hard coded value but I want to get the data from a simple web service on app startup on wake and when button is activated (similar to my xamarin.forms iphone app)

I've tried using the classes that I use on the forms app to get the data but I can't reference them. I've tried using httpclient and that doesn't work.

After googling it appears I am suppose to use a HandleWatchKitExtensionRequest delegate in the phone app to get the data in a dictionary and then display the data. I haven't been able to find any really simple examples of this, but I'm confused because since apple watch version 3 the watch has been autonomous with cell access and therefore it doesn't have the host app necessarily.

So what I'm asking, is can the watch actually consume a web service alone using a xamarin phone app and if so, is there any simple examples because I can't find any (that aren't from 2015).

Sorry if this is vague, or I sound like a newbie (I definitely am a newbie when it comes to xamarin but any pointers or help would be appreciated)

Answers

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai
  • KingspodKingspod Member

    Hi, Thanks for the reply I can't seem to find anything that references the WatchOS or Watchkit in the hellomobile project? I may be missing something obvious... Just want to know how the watch can consume a JSON web service on it's own if indeed that's possible?

Sign In or Register to comment.