两个方法:
1、查看屏幕的亮度
CGFloat screenBrightness = [[UIScreen mainScreen] brightness];
if (screenBrightness > 0) {
// todo
}
2、监听com.apple.springboard.lockcomplet
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
(void *)self,
screenLockStatus,
CFSTR("com.apple.springboard.lockcomplete"),
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
void screenLockStatus(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
PlaybackControlPlayer * playbackControlPlayer= (__bridge PlaybackControlPlayer *)observer;
NSString* lockState = (__bridge NSString*)name;
if([lockState isEqualToString:@"com.apple.sprin