0

I have created a iPhone application that supports accelerometer api. To detect acceleration of x,y and z position of iPhone. It works good.I reviewed a new watch kit Framework and its programming guide. Apple watch have default sensors to detect acceleration. I need to create a new watch app, to find apple watch acceleration. Some one said in stack overflow thread there is no direct access api to apple watch sensor(where is it mentioned in apple docs). Is it possible to do this work with apple watch?

  • apple watch extension does not support any of these apple api? (CoreMotion,CoreLocation, CoreData… )
  • Any alternatives suggestion?
vinoth87
  • 200
  • 1
  • 2
  • 16

2 Answers2

1

There is no way to do this with sensors on the Apple Watch. The code for your Watch App runs as an extension on the iPhone and not on the Apple Watch. This means that you can use Core Motion, Core Location, etc in your Apple Watch extension using the sensors on the iPhone. If you want the acceleration of the x, y, and z position of the iPhone then you can do that with the iOS APIs in your Watch extension on the iPhone.

Stephen Johnson
  • 5,293
  • 1
  • 23
  • 37
  • Thanks. So apple watch is used only for UI and user interactions. All other actions(location monitoring, motion detector, web service calls.....) are done by iPhone and shared data to apple watch. right? – vinoth87 Jan 21 '15 at 13:39
  • That is correct. You will have two parts to your app. You create a UI via a storyboard that is on the Apple Watch and then all of your code is in an extension that is on the iPhone. For example, here is how to use Core Location in the extension. http://stackoverflow.com/questions/27960108/how-to-calculate-current-location-in-watchkit-extension/27964325#27964325 – Stephen Johnson Jan 21 '15 at 13:44
  • Thanks again. - If i implemented Location manager in my watch extension file, then the prompted location alert should open in iPhone? (what if iPhone app not running) - Do we need to maintain separated sources for iPhone app and watch app? – vinoth87 Jan 21 '15 at 14:26
  • You will need to detect that the user has not authorized Core Location in your watch extension. If they have not, then you will need to instruct the user for how to authorize location updates. The user will need to do that in your iPhone app. If they authorize location updates in your iPhone app, then you watch app has permission as well. You can use a framework to share code between your watch and iPhone app. The binary for the iPhone and watch extension are in the same app bundle. – Stephen Johnson Jan 21 '15 at 14:54
0

This is going to change when Watch OS 2 would be released, in particular the extension would run on the watch and would have the access to Core Motion framework.

https://www.bignerdranch.com/blog/watchkit-2-hardware-bits-the-accelerometer/

MikeGer
  • 391
  • 2
  • 4