Skip to content

Instantly share code, notes, and snippets.

@innocuo
Forked from zachbrown-bm/notification.swift
Last active March 25, 2017 17:34
Show Gist options
  • Save innocuo/8c8480a165d76b990abbcc279acc3356 to your computer and use it in GitHub Desktop.
Save innocuo/8c8480a165d76b990abbcc279acc3356 to your computer and use it in GitHub Desktop.
Deliver an OSX notification with Swift
func showNotification(title : String, informativeText: String) -> Void {
let notification = NSUserNotification()
notification.identifier = "\(NSDate().timeIntervalSince1970)"
notification.title = title
notification.informativeText = informativeText
notification.soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter.default.deliver(notification)
}
//Example: showNotification("Some Title", "Description of notification.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment