I have a web app that uses wake lock (see below) - I have registered the origin trial and added the code to my index.html. - see https://lucid-franklin-4016c2.netlify.com/
When I load the page in the latest version of Android Chrome the phone stays awake, and the text-to-speech messages I use for this running app work fine.
I've also set it up as a PWA (service worker, manifest,... - all good in lighthouse). However, after "add page to home screen" and loading the PWA from there the phone does go to sleep. It continues to count time and can play sound files in the background but text-to-speech is deactivated.
Is this expected behaviour?
My key need is text-to-speech rather than to keep the phone awake as such, as geolocation seems to work while the phone is asleep anyway. Is there something else I could be doing?
// The wake lock sentinel.
let wakeLock = null;
// Function that attempts to request a wake lock.
export const requestWakeLock = async cb => {
try {
wakeLock = await navigator.wakeLock.request("screen");
wakeLock.addEventListener("release", () => {
console.log("Wake Lock was released");
});
console.log("Wake Lock is active");
} catch (err) {
console.error(`${err.name}, ${err.message}`);
cb({
tag: "error",
payload: "wakeLock not supported"
});
}
};