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)
happening or moving quickly or within a short time, especially in a smooth and easy way: The police took swift action against the rioters. Thank you for your swift reply.
How is SWIFT governed? SWIFT is a cooperative company under Belgian law and is owned and controlled by its shareholders (financial institutions) representing approximately 2,400 Shareholders from across the world.
The SWIFT messaging network is a component of the global payments system. SWIFT acts as a carrier of the "messages containing the payment instructions between financial institutions involved in a transaction".
It's clear that SWIFT is a trusted partner to the Australian financial services industry. Every day, institutions in Australia safely and securely send and receive approximately 700,000 individual and many more bulk transactions through the SWIFT network.
Some notifications are not shown if the application is the foreground/active application at the time the notification is delivered. See NSUserNotification
's presented
property for more info.
For example, when you are in iTunes and a new song starts playing, you already see which song is playing and there's no need for a banner to be shown.
Note that you can still get notified when a notification is delivered (and check presented
) by providing a delegate to NSUserNotificationCenter
, including overriding the presentation behavior by implementing userNotificationCenter:shouldPresentNotification:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With