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");
        }
        
        
        
    });
    
}

  

posted @ 2017-02-20 13:59  曹县三胖暴打大猩猩  阅读(1665)  评论(0编辑  收藏  举报