Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Heart Rate and Accelerometer APIs on Apple Watch for Automatic Activity Tracking #35

Open
1 of 9 tasks
nelsonic opened this issue May 12, 2017 · 11 comments
Open
1 of 9 tasks

Comments

@nelsonic
Copy link
Member

nelsonic commented May 12, 2017

Hi @sohilpandya,
Hope your morning is going well!
Hope your neck is feeling much better and you're $.ready() to receive your next mission! 😉

You've done a great job so far of building the (Alpha) Time App
and it's going to be even better once our API is Live!

Ideal "User Story"

As a person using the dwyl app
I want to track my activities automatically
So that I don't have to think about (remember to) manually start a timer on my device/app

As you recall from our initial discussion last November on doing Apple Watch Development,
the reason for having an Apple Watch (Native) App is not just to be able to "Tap to start a timer".
(or as a "Vanity Project" to say that we know how to write swift @dwyl ...)
The beauty "Wearable" is that has sensors that can be used to trigger events! e.g:

  • Sleeping
  • Exercising
  • Meditating
  • Working on something that requires concentration (what is the heart rate pattern for this?) 💭

While you are "waiting" for the API to be ready ...
(promise I'll be back working on API as soon as my current client DevOps work is done!)
I thought it would be a good time to start investigating other Apple Watch (WatchKit) APIs!

I know Heart Rate Monitoring might appear to be a "side track" from the "Task Timing" project,
But actually tapping into the Heart Rate Monitor gets us to our Goal of Automatic Activity Tracking (without requiring the user to manually start the timer)!

Todo / Tasks

  • Investigate how sleep trackers work Investigate how Sleep Trackers Work sleep#8
  • Investigate using the Apple HealthKit API: https://developer.apple.com/healthkit
  • How can we use Heart Rate and Accelerometer API to automatically track activity?
    • how complicated is it to sample the heart rate?
      • Determine what frequency we should sample heart rate.
      • Calculate person's resting heart rate by sampling at several times during the day
  • what is the typical frequency required to effectively track heart rate during various activities:
    • Concentrated (deep) work
    • physical activity
    • Resting/Sleeping
  • Can we export this data to our own API/Backend (preferably stream in real-time but if not via REST API?)

Watch this video: https://youtu.be/CfbvT_vCcwc it's pretty much the "Killer App" for Apple Watch (excuse the terrible pun! but it's a compelling reason to own and give one to a loved one!)

As usual, make sure you ask any relevant questions on GitHub first,
then link back to GH from StackOverflow so we continue to keep our knowledge here.
(which appears to be pretty active for http://stackoverflow.com/questions/tagged/apple-watch ...)

Relates to: dwyl/sleep#7

@sohilpandya
Copy link
Member

sohilpandya commented May 25, 2017

@nelsonic ❤️ this and I'll be looking into this very soon (next week 😟), really excited to look into this. 👍

@sohilpandya
Copy link
Member

I'd like to spike this whole user story that you've created above, Giving myself a full day to see how far I can get with all the items you've mentioned above.

@sohilpandya
Copy link
Member

sohilpandya commented Jul 11, 2017

Investigated Sleep Tracking on this issue dwyl/sleep#8

Healthkit

All health kit data is collected using either the iPhone or Watch, the data collected is stored in an encrypted database called HealthKit store Which can be accessed using HKHealthSrore class.

Both iPhone and the Watch have its own HealthKit store and the data is synced between the two devices. but, old data is removed from the Watch to save space.

Health is a sensitive topic hence Apple provide fine grain control to the user in terms of what information is shareable to the third party app. We would have to specify exactly what data we need from health kit. (heart rate, steps, birthdate, weight, height, sex etc.)

screen shot 2017-07-11 at 12 32 42

Apple states that any app that uses health kit must be primarily designed to provide heath or fitness services and provide a privacy policy.

@sohilpandya
Copy link
Member

Nelson asked a question regarding how the data is stored on the iPhone in the first place and how 3rd party apps can access it.

  • iPhone/Watch start recording data automatically, this is stored in Healthkit Store which is an encrypted database.
  • This is the information that is present in the Health app and Apple use it to display information to the user.
    img_fa97202275fc-1
  • If a 3rd party app wants to use the data, then they need to ask for permission from the user to access the data. Even then the app can only ask for data when it is running and in the foreground, access to Healthkit data is not possible in the background (security reasons)
  • I'll show a brief example of how to access this data in a tutorial.

@sohilpandya
Copy link
Member

1.5 Days spent on this issue in total. (estimated only 1 day)

@nelsonic
Copy link
Member Author

@sohilpandya did you record a video summary (or our standup where the functionality was discussed) ?

@sohilpandya
Copy link
Member

I have the hangout that we recorded on the 11th July, where we walked through the issue as well as the demo app which showed user the total number of steps. #43

@nelsonic
Copy link
Member Author

@sohilpandya sweet! have you uploaded it somewhere?

@sohilpandya
Copy link
Member

@nelsonic I've got quite a few of them stored away on the laptop, not anywhere online, I'll get them transferred to our Gdrive folder at some point today. :)

@sohilpandya
Copy link
Member

Here is the link https://drive.google.com/drive/u/1/folders/0BzAgO1bmVDtpSU9KZTZEaTdOS00

11th July is on the drive now.

@nelsonic
Copy link
Member Author

@sohilpandya thanks! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants