IOS – Persistently or aggressively enabling Low Power Mode

iospower-management

I love the Low Power Mode feature. When I'm travelling or in other situations where reliable communication is more important than user experience, I want to always have it enabled, sometimes for days at a time.

However, iOS automatically turns it off after the phone has been charged, requiring me to remember to go in and re-enable it after unplugging my phone. I occasionally forget.

Is there any way (including third-party apps, excluding rooting/jailbreaking) for me to automatically or persistently enable Low Power Mode, aside from the system's automatic behaviour at 20%? A way to leave it on indefinitely, or a way to have it automatically activate earlier (such as at 50%), or a way to activate it based on a schedule?

If there's no user-accessible way to do this yet, I would also be interested in knowing if there are any mechanisms in the operating system (URL schemes, framework APIs) that could potentially be used to control Low Power Mode.

Best Answer

Yes, the _CDBatterySaver API in the CoreDuet (Private*)Framework can be used to toggle low power mode.

An example invocation, untested:

#import <CoreDuet/CoreDuet.h>
#import <objc/runtime.h>

-(void)setLowPowerMode:(BOOL) isOn {
    _CDBatterySaver *batterySaver = [objc_getClass("_CDBatterySaver") batterySaver];
    int nextState;

    if(isOn) {
        nextState = 1;
    } else {
        nextState = 0;
    }

    if([batterySaver setMode:nextState]) {
        NSLog(@"Set power mode state");
    }
}

I'd wrap this in an app with a background task to watch for low power mode (both well documented APIs). This can be done with Xcode as Apple allow building and installation of apps to your phone without requiring a developer license (IIRC).

*See answer to question how to import private frameworks in xcode. Note: header files can be found on GitHub without the need for a jailbroken device.