04-20-2018 00:00 - edited 04-20-2018 00:01
04-20-2018 00:00 - edited 04-20-2018 00:01
Hi,
I'm working on adding the heart rate sensor on my own clock face.
It seems working in the simulator (showing 65 BPM), but when deploying the app on my girlfriend's Ionic, the label is empty.
Here is basically what I'm doing :
import document from "document";
import { HeartRateSensor } from "heart-rate";
import * as util from "../common/utils";
// Get a handle on the <text> element.
const heartRateLabel = document.getElementById("heartRateLabel");
// Create a new instance of the HeartRateSensor object.
const hrm = new HeartRateSensor();
hrm.onreading = function() {
// Update the <text> element with the current heart rate sensor value.
heartRateLabel.text = util.monoDigits(hrm.heartRate || 0);
// Stop monitoring the sensor.
hrm.stop();
}
export function update() {
// Begin monitoring the sensor.
hrm.start();
}
import clock from "clock";
import * as activity from "activity";
import * as battery from "battery";
import * as date from "date";
import * as heartRate from "heartrate";
import * as time from "time";
import * as util from "../common/utils";
// Update the clock every second.
clock.granularity = "seconds";
// Each second.
clock.ontick = (evt) => {
heartRate.update();
battery.update();
const todayDate = evt.date;
date.update(todayDate);
time.update(todayDate);
activity.update();
}
Am I wrong somewhere?
Answered! Go to the Best Answer.
Best Answer04-22-2018 23:54
04-22-2018 23:54
I've found the problem.
When we update an app/clock face, the Fitbit App doesn't re-ask for permission, so the app doesn't have access to HR.
I've installed another clock and then mine back and it works properly now.
Best Answer04-20-2018 05:55
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-20-2018 05:55
Did you enable the Heart Rate Sensor permission in the package.json?
04-20-2018 06:39
04-20-2018 06:39
Yes it is. 😕
Best Answer04-21-2018 05:01
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
04-21-2018 05:01
My very simple clockface (still very experimental) has a miraculously working HR measurement in this way
// Reading heartrate
const hrm = new HeartRateSensor();
hrm.onreading = function() {
heartrateHandle.text = `${hrm.heartRate}`;
}
hrm.start();it shall be noted that for some reason it is not under the clock.ontick block
04-22-2018 23:54
04-22-2018 23:54
I've found the problem.
When we update an app/clock face, the Fitbit App doesn't re-ask for permission, so the app doesn't have access to HR.
I've installed another clock and then mine back and it works properly now.
Best Answer