Is there a JavaScript API to detect low power mode for iOS 11 Safari? I have not found any info on the subject yet.
A workaround to get this done is:
Put a video (hidden) in the webpage with autoplay 'on', and then detect the 'suspend' event for that video. Whenever it is invoked, 'power mode is on'.
Here is the script:
const videoElement = document.getElementById('ID_of_video');
videoElement.addEventListener('suspend', () => {
// suspend invoked
// show play button
// iphone is in low power mode
});
videoElement.addEventListener('play', () => {
// video is played
// remove play button UI
// iphone is not in low power mode
});
You can also read the explanation here: Playing video when low power mode is on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With