Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom app: how to keep it running even when display goes to sleep

ANSWERED

Hello,

I've developed a custom app which sends HR values to the companion app, which in turn forwards them to a nodejs server via fetch.

Unfortunately, the moment the display goes to sleep the app stops sending the values to the companion.

Is there a workaround for that?

Thank you.

Carlo

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

ontick() won't be called when the display goes off, so don't put your comms code in there.

If an app that's closing after 2 minutes, set appTimeoutEnabled to false.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
3 REPLIES 3

ontick() won't be called when the display goes off, so don't put your comms code in there.

If an app that's closing after 2 minutes, set appTimeoutEnabled to false.

Peter McLennan
Gondwana Software
Best Answer

Thanks!

I had already put this into my app code but it did't work:

 
import { me as appbit } from "appbit";
appbit.appTimeoutEnabled = false;
 
Is there anything I am missing?
Carlo
Best Answer
0 Votes

My bad...

I had this at the bottom of my code which was preventing all the sensors from sending data...

 

display.addEventListener("change", () => {
display.on ? sensors.map(sensor => sensor.start()) : sensors.map(sensor => sensor.stop());
});
 
Solved, thanks!
Best Answer