06-28-2020 07:33 - edited 06-28-2020 07:52
06-28-2020 07:33 - edited 06-28-2020 07:52
What is the best way to create a reminder app for Fitbit versa.
First thing, is it possible at all in Fitbit ecosystem, given the fact that companion is running in mobile device and is dependent on Mobile OS to keep the app running in background.
For example, I Tried below companion code from Fitbit developer forum. I could not seem to get it work, console log shows only for the first time 5 mins after launch, but not after next 5 minutes.
(Also is there any way In developer mode to reduce the standard wakeInterval duration. Because while developing/testing waiting 5 minutes is a-lot, Would like to do quick build-test tries )
Thanks for any help 🙂
import { me as companion } from "companion";
if (!companion.permissions.granted("run_background")) {
console.warn("We're not allowed to access to run in the background!");
}
const MILLISECONDS_PER_MINUTE = 1000 * 60;
// Tell the Companion to wake after 5 minutes
companion.wakeInterval = 5 * MILLISECONDS_PER_MINUTE;
// Listen for the event
companion.addEventListener("wakeinterval", doThis);
// Event happens if the companion is launched and has been asleep
if (companion.launchReasons.wokenUp) {
doThis();
}
companion.onwakeinterval = evt => {
console.log("Companion was already awake - onwakeinterval");
doThis();
}
function doThis() {
console.log("Wake interval happened!");
}
06-28-2020 13:16
06-28-2020 13:16
I don't think the wake interval can be reduced below the minimum. I think it has to be this way to prevent the operating system from killing things to save battery use.
The harder problem is how to notify the watch user. Apps can't run on the background on the watch, nor can they be started from the companion. The companion API doesn't provide methods for sending notifications (like what happens with SMSs).
06-29-2020 00:25
06-29-2020 00:25
Thanks Peter,
So ok there isn't any way at the moment to create reminder like apps for Fitbit given the fact that, niether companion app nor app in watch can run in background or wake at intervals. Cheers
06-29-2020 10:15
06-29-2020 10:15
Hello vijeth,
I have a task that I fire hourly, but it is as part of a watchface. As Gondwana said there is no background tasking and it does not appear it will ever be an option.
I do understand as doing such opens up a whole new class of potential security vulnerabilities.
On the other hand, if you are willing to write a whole new watchface to support your app, it is possible.
In practice, I still have to check if events have passed while something else ran, and I do have to restart interval timers on restart as well; as a watchface you pretty much own the foreground, but you do have to account for when your app is displaced, even momentarily.
Regards,
Reign
06-30-2020 05:04
06-30-2020 05:04
Thanks Reign, appreciate the detailed answer. Cheers