04-11-2020 12:12
04-11-2020 12:12
Hi, im developing a clock face, it was working fine until i started having issue with the heart rate and the body presence sensors, when i run the clock on the simulator for the first time the heart rate sensor works fine but when i switch between os like from versa to ionic or ionic to versa the heart rate sensor doesn't work as if it isnt initiated and the body sensor too, also the users noticed that the heart rate is always OFF
Here is the heart rate code im using
if (HeartRateSensor && appbit.permissions.granted("access_heart_rate")) {
const hrm = new HeartRateSensor({ frequency: 1 });
hrm.addEventListener("reading", () => {
currentHeartRate = hrm.heartRate;
console.log("current heart rate= " + currentHeartRate + "/" + hrm.heartRate);
});
hrm.start();
if (BodyPresenceSensor) {
const body = new BodyPresenceSensor();
body.addEventListener("reading", () => {
if (!body.present) {
console.log("Heart set to false");
isWatchOnWrist = false;
} else {
console.log("Heart set to true");
isWatchOnWrist = true;
}
});
body.start();
}else isWatchOnWrist = true;
}
the console.log is never called after the second clock launch and im using the isWatchOnWrist to check if the watch is on wrist and display OFF or the current heart rate.