Auto brightness overrides screen brightness value which I have set for my application. I set brightness by
[[UIScreen mainScreen] setBrightness:0.1];
I want to turn off auto brightness programatically
I am developing enterprise app so there is no issue for using private api
I tried with UIScreenBrightnessDidChangeNotification but its not update my value
- (void)viewDidLoad {
[super viewDidLoad];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserverForName:UIScreenBrightnessDidChangeNotification
object:nil
queue:nil
usingBlock:^(NSNotification *notification)
{
NSLog(@"Brightness changed: %f", [[UIScreen mainScreen] brightness]);
dispatch_async(dispatch_get_main_queue(), ^{
[[UIScreen mainScreen] setBrightness:0.1];
});
}];
}
Listen to the brightnessDidChangeNotification and set the brightness back where you want it in your handler.
Of course you also need to add code to check the brightness after the app has been in background (and may have missed notification(s)).