Last active
January 10, 2025 14:21
-
-
Save MTACS/719125f138eaa6527e282bc1875d311c to your computer and use it in GitHub Desktop.
Toggle Low Power Mode programmatically on iOS 16+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iOS 16+ | |
// _CDBatterySaver class doesn't exist on versions higher than 16.0 | |
@interface _PMLowPowerMode : NSObject | |
+ (id)sharedInstance; | |
- (NSInteger)getPowerMode; | |
- (void)setPowerMode:(NSInteger)arg0 fromSource:(id)arg1; | |
- (void)setPowerMode:(NSInteger)arg0 fromSource:(id)arg1 withCompletion:(id)arg2; // Don't use if completion is nil, callback requires non null parameter | |
@end | |
%hook Class | |
- (void)toggleLowPower { | |
_PMLowPowerMode *lowPowerMode = [%c(_PMLowPowerMode) sharedInstance]; | |
BOOL active = [lowPowerMode getPowerMode] == 1; | |
[lowPowerMode setPowerMode:!active fromSource:@"SpringBoard"]; | |
} | |
%end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment