swift - iOS get heart rate from Apple Watch in near real time -


i need make app records heart rate data in near real time , send data server possible.

first took approach: watch os 2.0 beta: access heart beat rate

in fact working fine. there new heart rate data in healthkit every 5 seconds. have problem can't sync server.

my first approach watch app. watch sending data server. doesn't work because screen turns black on watch, stops sending.

my next approach query healthkit on iphone every 5 seconds new data. works, long app in foreground.

then saw there's kind of background functionality watches healthkit , revokes app background , can something.(enablebackgrounddeliveryfortype) doesn't seem work heart rate (the apple documentation says things steps doesn't work, guess heart rate 1 of those).

i'm stuck now. know how it? need background task executed every 5-10 seconds on iphone. seems impossible

update

as noticed @bootmaker, apple made background mode available hkworkout apps in watchos 3, it's working now. have run hkworkoutsession , keep heartrate delivery in real time when app in background (dark screen on watch)

the closest going while watch app open.

why i'm stating this?

  1. there 2 healthkit's database (one @ iphone , @ apple watch). when sync arbitrary , decided o.s.

  2. the closest going to real time when don't have password locking screen in iphone or apple watch. either way, there's no guarantee sync happen every time new measure added apple watch's healthkit

  3. the way force heart rate sensor working in real time via workouts or observer while apple watch app in foreground.

  4. background delivery not available apple watch apps.

  5. watch os 2 request sensor measure automatically (in background) every 10 minutes minimum.

there's no other workaround, if need real time longer periods, or while user not using app, you need use specialized wearable.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -