Reputation:
Hello notifications are not displayed on Mac OS Catalina, here is my code:
func showNotification() {
let notification = NSUserNotification()
// All these values are optional
notification.title = "Test of notification"
notification.subtitle = "Subtitle of notifications"
notification.informativeText = "Main informative text"
notification.soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter.default.deliver(notification)
}
I noticed that in my mac application now when I open the application a notification request appears. Maybe I have to implement that? But I can not find any documentation on it. How to view local notification...
Even with UserNotification it does not work
Upvotes: 0
Views: 1142
Reputation: 2709
The NSUserNotification
has been deprecated past MacOS 10.14 as per https://developer.apple.com/documentation/foundation/nsusernotification
Instead you might want to have a look at the UserNotification
framework as in https://developer.apple.com/documentation/usernotifications?language=objc
And in addition it is now crucial to request permission from users to authorize notifications.
Upvotes: 3