越狱ios有没有简单的办法判断手机是否锁屏

如题 , 想判断下手机是否锁屏。还有 锁屏的时候也有两个状态 一个是黑屏状态和点亮状态 。有没有办法判断呢 。最好是越狱的方法 。简单点可能。

想判断楼主是否做了功课。还有 做功课也分两种 一种是网上随便搜了一下和自己深入研究了一下 。有没有办法判断呢 。最好是直观的方法 。简单点可能。

3 Likes

/* Register app for detecting lock state */

 -(void)registerAppforDetectLockState {

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

     NSLog(@"com.apple.springboard.lockstate = %llu", state);
     UILocalNotification *notification = [[UILocalNotification alloc]init];
     notification.repeatInterval = NSDayCalendarUnit;
     [notification setAlertBody:@"Hello world!! I come becoz you lock/unlock your device :)"];
     notification.alertAction = @"View";
     notification.alertAction = @"Yes";
     [notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
     notification.soundName = UILocalNotificationDefaultSoundName;
     [notification setTimeZone:[NSTimeZone  defaultTimeZone]];

     [[UIApplication sharedApplication] presentLocalNotificationNow:notification];

  });

 }
2 Likes

楼主应该不是要这个, 看IOKit 吧