It doesn't look like WatchKit released today has such API included.
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
We will get it most likely next year, when Apple will allow us to build full applications. Until now it's only UI, Glances and Notifications.
Update: Apple has provided developer APIs for it now. Check casillas's answer.
No. Direct access to the Apple Watch sensors (which include the accelerometer) is not possible.
As always, if this is something you'd like, please file a request for it at https://bugreport.apple.com.
Sensor Data information is now available in
Watchkit for watchOS 2.0
.You could check this information in the following session which is total 30 minutes presentation.If you do not want to watch entire session, then you directly jump to the
CoreMotion
andHealthKit
features which is in between 22-28 min:WatchKit for watchOS 2.0 Session in WWDC 2015
Heart Rate Implementation
https://developer.apple.com/documentation/healthkit/hkworkout
Accelerometer Implementation
Here is the implementation of accelerometer in WatchKit Extension, Here is the reference:
Update for watchOS 4 & iOS 11: Gyroscope data (rotation rate) is now also available and all of the sensor data from the watch can be accessed via the updated CoreMotion interface.
More specifically CMDeviceMotion gets you:
Implementation of the accelerometer with
CMDeviceMotion
:Notes on the implementation above:
While this method will get you from A to B in terms of getting some real time data from the Apple Watch, a much nicer and definitely more production ready version awaits in this official Apple tutorial, which explains how to separate the sensor logic from the InterfaceController in a separate model etc. - extremely useful, in my opinion.