10-29-2018 16:37
10-29-2018 16:37
Hello,
Apologies if this is in other topic. I was looking around and couldn't find a solution for the issue I have. If there is other thread with information that can help me with the issue I'm about to explain, please let me know.
I want to wake up the companion app every a certain time, for debugging purposes I put 5 minutes.
This is the code:
import { me } from "companion";
const MINUTE = 1000 * 60;
me.wakeInterval = 5 * MINUTE;
console.log("Wake Interval " + JSON.stringify(me.launchReasons));
me.onwakeinterval = evt => {
console.log("Inside onwakeinterval");
if (me.launchReasons.wokenUp) {
// The companion started due to a periodic timer
console.log("Started due to wake interval!");
...
}
};This a link to a printscreen of the logs: https://www.dropbox.com/s/y0kv9d0ov8dz3qg/IMG_1271.jpg?dl=0
What I noticed from the logs is:
My questions are:
me.onwakeinterval = evt => {...};
Hope you can help me with these problems.
Thanks in advance.
Answered! Go to the Best Answer.
Best Answer11-02-2018 18:15
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.
11-02-2018 18:15
The wakeInterval is only guidance to the mobile runtime to wake the companion, as per https://dev.fitbit.com/build/guides/companion/#periodic-wake-interval
There are 2 states your companion needs to listen for:
1. onwakeinterval - this event fires when your companion is already running and the interval elapses.
2. the launchReason.wokenUp
import { me } from "companion";
const MINUTE = 1000 * 60;
me.wakeInterval = 5 * MINUTE;
me.onwakeinterval = evt => {
console.log("Companion was already awake - onwakeinterval");
}
if (me.launchReasons.wokenUp) {
// The companion started due to a periodic timer
console.log("Started due to wake interval!");
}
Best Answer11-02-2018 18:15
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.
11-02-2018 18:15
The wakeInterval is only guidance to the mobile runtime to wake the companion, as per https://dev.fitbit.com/build/guides/companion/#periodic-wake-interval
There are 2 states your companion needs to listen for:
1. onwakeinterval - this event fires when your companion is already running and the interval elapses.
2. the launchReason.wokenUp
import { me } from "companion";
const MINUTE = 1000 * 60;
me.wakeInterval = 5 * MINUTE;
me.onwakeinterval = evt => {
console.log("Companion was already awake - onwakeinterval");
}
if (me.launchReasons.wokenUp) {
// The companion started due to a periodic timer
console.log("Started due to wake interval!");
}
Best Answer