iOS device is locked/unlocked (判断手机屏幕是否锁屏)

#import <notify.h>

-(void)checkDeviceLockScreenState {
    
    int notify_token;
    notify_register_dispatch("com.apple.springboard.lockstate",     &notify_token,dispatch_get_main_queue(), ^(int token) {
        uint64_t state = UINT64_MAX;
        notify_get_state(token, &state);
        if(state == 0) {
            NSLog(@"unlock device");
        } else {
            NSLog(@"lock device");
        }
        
        
        
    });
    
}

  

原文地址:https://www.cnblogs.com/thbbsky/p/6419216.html