iOS does not detect when user manually switches to low power mode
See original GitHub issueI am using v5.6.1
I want to detect if user triggered power save on device.
I thought that this would work but this triggers on power cable in.
Is there any other way to get lowPowerMode
only when suer change this phone settings?
import { NativeEventEmitter, NativeModules } from 'react-native'
const deviceInfoEmitter = new NativeEventEmitter(NativeModules.RNDeviceInfo);
async componentDidMount() {
this.batteryListener = deviceInfoEmitter.addListener('RNDeviceInfo_powerStateDidChange', status => {
// {batteryState: "charging", batteryLevel: 0.75, lowPowerMode: true}
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
iOS does not detect when user manually switches to low ...
I am using v5.6.1. I want to detect if user triggered power save on device. I thought that this would work but this...
Read more >Low power mode not popping up - Apple Support Communities
whene my battery goes to 20%, the low power mode is not showing up like usually others do. I have to do manually...
Read more >How to force your iPhone to always stay in Low Power Mode
To check, go to iPhone Settings > Battery and enable Low Power Mode (if not already). Now, turn off the switch for Low...
Read more >How to Automate Low Power Mode When Your iPhone Battery ...
1. Open the Shortcuts app on your iPhone. 2. Select the Automation tab at the bottom of the screen, then tap the +...
Read more >Low power mode detection in JavaScript for iOS11?
For iOS 16 Safari, "Low Power Mode" (or say power saving mode) can be detected by checking actual interval of setInterval , because ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh! You are right, looks like we might be missing something here
https://github.com/react-native-community/react-native-device-info/blob/2dea0575e892466c3ddc0965fafb2252f2466497/ios/RNDeviceInfo/RNDeviceInfo.m#L78-L89
Specifically something like
https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/LowPowerMode.html
I am happy to merge a PR that does this, it should be a quick hack - go after it directly in node_modules to develop + test it by hooking that and emitting a new powerStateDidChange event, when you get it working use https://github.com/ds300/patch-package (fantastic! if you’ve never seen it) so that your fix never stops working for you, and submit the change as a PR, I can do a release quickly just no time for the testing (that’s the part that really takes the time, IMHO)
I welcome PRs, and will merge and release reasonable solutions