Programmatically check state of do not disturb on OS X

前端 未结 4 1125
悲&欢浪女
悲&欢浪女 2021-02-04 11:35

Using Objective-C, how can I programmatically check the state of the system \"Do Not Disturb\" setting on OS X? I\'m fine with using hacks or private APIs since I don\'t need to

4条回答
  •  星月不相逢
    2021-02-04 11:44

    In Objective-C, you can access the value like this:

    NSUserDefaults* defaults = [[NSUserDefaults alloc]initWithSuiteName:@"com.apple.notificationcenterui"];
    BOOL dnd = [defaults boolForKey:@"doNotDisturb"];
    

提交回复
热议问题