Can someone give an example of sending a test notification from a Cocoa app to Notifications Center? eg. when I click on an NSButton
Can someone give an example of sending a test notification from a Cocoa app to Notifications Center? eg. when I click on an NSButton
@alexjohnj's answer updated for Swift 5.2
In AppDelegate
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Set delegate
NSUserNotificationCenter.default.delegate = self
}
And then confirm to NSUserNotificationCenterDelegate as
extension AppDelegate: NSUserNotificationCenterDelegate {
func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
true
}}