-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
DisplaceKit/DPLUserNotificationCenter/Extensions/NSURL+DPLUserNotificationCenter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// NSURL+DPLUserNotificationCenter.h | ||
// DisplaceKit | ||
// | ||
// Created by Marcel Dierkes on 20.02.21. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSURL (DPLUserNotificationCenter) | ||
@property (class, nonatomic, readonly) NSURL *dpl_notificationPreferencesURL; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
18 changes: 18 additions & 0 deletions
18
DisplaceKit/DPLUserNotificationCenter/Extensions/NSURL+DPLUserNotificationCenter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// NSURL+DPLUserNotificationCenter.m | ||
// DisplaceKit | ||
// | ||
// Created by Marcel Dierkes on 20.02.21. | ||
// | ||
|
||
#import "NSURL+DPLUserNotificationCenter.h" | ||
#import "DPLDefines.h" | ||
|
||
@implementation NSURL (DPLUserNotificationCenter) | ||
|
||
+ (NSURL *)dpl_notificationPreferencesURL | ||
{ | ||
return [self URLWithString:@"x-apple.systempreferences:com.apple.preference.notifications"]; | ||
} | ||
|
||
@end |
23 changes: 23 additions & 0 deletions
23
DisplaceKit/DPLUserNotificationCenter/Extensions/NSWorkspace+DPLUserNotificationCenter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// NSWorkspace+DPLUserNotificationCenter.h | ||
// DisplaceKit | ||
// | ||
// Created by Marcel Dierkes on 20.02.21. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef void(^DPLOpenNotificationsCompletionHandler)(NSRunningApplication *_Nullable, | ||
NSError *_Nullable); | ||
|
||
@interface NSWorkspace (DPLUserNotificationCenter) | ||
|
||
/// Opens the notifications pane in System Preferences. | ||
/// @param completionHandler An optional completion handler, called on a private queue | ||
- (void)dpl_openNotificationPreferencesWithCompletionHandler:(nullable DPLOpenNotificationsCompletionHandler)completionHandler; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
30 changes: 30 additions & 0 deletions
30
DisplaceKit/DPLUserNotificationCenter/Extensions/NSWorkspace+DPLUserNotificationCenter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// NSWorkspace+DPLUserNotificationCenter.m | ||
// DisplaceKit | ||
// | ||
// Created by Marcel Dierkes on 20.02.21. | ||
// | ||
|
||
#import "NSWorkspace+DPLUserNotificationCenter.h" | ||
#import "DPLDefines.h" | ||
#import "NSURL+DPLUserNotificationCenter.h" | ||
|
||
@implementation NSWorkspace (DPLUserNotificationCenter) | ||
|
||
- (void)dpl_openNotificationPreferencesWithCompletionHandler:(DPLOpenNotificationsCompletionHandler)completionHandler | ||
{ | ||
Auto prefURL = NSURL.dpl_notificationPreferencesURL; | ||
Auto config = [NSWorkspaceOpenConfiguration configuration]; | ||
config.addsToRecentItems = NO; | ||
|
||
[self openApplicationAtURL:prefURL | ||
configuration:config | ||
completionHandler:^(NSRunningApplication *app, NSError *error) { | ||
if(completionHandler != nil) | ||
{ | ||
completionHandler(app, error); | ||
} | ||
}]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters