I am learning Swift and wanted to display a simple user notification as a test.
My build is successful, but no banner is shown, instead, the notification is silently added to the list of notifications. I have verified 'Do Not Disturb' is off, I tried the same in AppleScript, successfully and once when fiddling around with NSUserNotificationAlertStyle
and the code in the info.plist of my application, I got a successful, non-silent alert (not a banner).
However, this only happened once.
I have created a new project, with Swift files and without storyboards. My AppDelegate.swift contains
import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification?) {
var notification:NSUserNotification = NSUserNotification()
notification.title = "Title"
notification.subtitle = "Subtitle"
notification.informativeText = "Informative text"
notification.soundName = NSUserNotificationDefaultSoundName
notification.deliveryDate = NSDate(timeIntervalSinceNow: 5)
var notificationcenter:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
if let notificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter() {
notificationcenter.scheduleNotification(notification)
}
}
func applicationWillTerminate(aNotification: NSNotification?) {
// Insert code here to tear down your application
}
}
And my info.plist does not contain the NSUserNotificationAlertStyle
mentioned earlier, for this shouldn't be necessary for banners, I believe.
Lastly, yes, application "test" (for that's what I've named it) is set to show banners, as such.
Summarised: My application successfully makes notifications, and these will be added to the list of notifications, but not shown as a banner.
(I am using OS X Yosemite 10.10. I hope this issue has nothing to do with the beta)