03-18-2019 14:49
03-18-2019 14:49
Hi,
I'm trying to improve my watch-face, however I'm not receiving any heartRate readings? This exported function is imported inside another file and then being called. Any help would be great!
import { HeartRateSensor } from "heart-rate"; import document from 'document'; // Initialises the heart rate. export default function outputHeartRate() { const hrm = new HeartRateSensor({ frequency: 1 }); const heartEl = document.getElementById('heart'); hrm.addEventListener("reading", () => { console.log(`Current heart rate: ${hrm.heartRate}`); heartEl.text = hrm.heartRate; }); hrm.start(); }
03-18-2019 15:07
03-18-2019 15:07
Looks ok.
Did you request the access_heart_rate permission?
03-18-2019 15:20
03-18-2019 15:20
I've requested the heart rate permission via the package.json, I've got it working by moving the instantiating of the HeartRateSensor outside of the exported function. Do you know why that would make it work? Thanks!