Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell if a Health Kit sample came from an Apple Watch?

Health App displays a Watch icon when the source was an Apple Watch.

I'd simply like to get the same information that the Health App is using to determine the type of source. HKSource doesn't seem to provide that.

like image 837
TealShift Avatar asked Jun 29 '15 07:06

TealShift


1 Answers

since iOS 9, samples of type HKSample have the property device of type HKDevice.

https://developer.apple.com/library/prerelease/ios/documentation/HealthKit/Reference/HKDevice_ClassReference/index.html

HKDevice tells you everything about the source device of the sample.

HKDevice.model describes the hardware type. At the time of writing, Apple does not document what values Apple uses in HKDevice.model. In my experiments, I found values "iPhone" and "Watch".

like image 176
Gerd Castan Avatar answered Oct 03 '22 20:10

Gerd Castan