//
// N o t i f y . s w i f t
// R S w i t c h
//
// C r e a t e d b y h r b r m s t r o n 8 / 2 4 / 1 9 .
// C o p y r i g h t © 2 0 1 9 B o b R u d i s . A l l r i g h t s r e s e r v e d .
//
import Foundation
import Cocoa
extension AppDelegate : NSUserNotificationCenterDelegate {
func notifyUserWithDL ( title : String ? = nil , subtitle : String ? = nil , text : String ? = nil ) -> Void {
let notification = NSUserNotification ( )
notification . title = title
notification . subtitle = subtitle
notification . informativeText = text
notification . hasActionButton = true
notification . actionButtonTitle = " Download "
notification . soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter . default . delegate = self
NSUserNotificationCenter . default . deliver ( notification )
}
func notifyUser ( title : String ? = nil , subtitle : String ? = nil , text : String ? = nil ) -> Void {
let notification = NSUserNotification ( )
notification . title = title
notification . subtitle = subtitle
notification . informativeText = text
notification . soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter . default . delegate = self
NSUserNotificationCenter . default . deliver ( notification )
}
func userNotificationCenter ( _ center : NSUserNotificationCenter , shouldPresent notification : NSUserNotification ) -> Bool {
return ( true )
}
func userNotificationCenter ( _ center : NSUserNotificationCenter , didActivate notification : NSUserNotification ) {
print ( notification )
}
}