美文网首页
detect lockstate and displaystat

detect lockstate and displaystat

作者: 萝BAIBAI | 来源:发表于2016-01-15 11:22 被阅读176次
    - (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 = NSCalendarUnitDay;
    //        [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];
            
        });
    }
    

    需要

    #import <notify.h>
    

    另外三个系统通知

    "com.apple.iokit.hid.displayStatus"
    "com.apple.springboard.hasBlankedScreen"
    "com.apple.springboard.lockcomplete"
    

    相关文章

      网友评论

          本文标题:detect lockstate and displaystat

          本文链接:https://www.haomeiwen.com/subject/bvjhkttx.html