Open hood opened 4 months ago
NSUserNotification is an old depreciated api. (see: https://developer.apple.com/documentation/foundation/nsusernotification?language=objc) The newer API for Notifications is called, UNUserNotificationCenter, (https://developer.apple.com/documentation/usernotifications/asking-permission-to-use-notifications?language=objc)
The newer API has a more complicated handshake, you need to request permissions to present the notification, then you can start sending messages to the Notification center.
What is happening with the code in the example is it causing a prompt to ask permission and if you don't click on that first notification and grant permission it doesn't present ANY further notifications.
To get the example to run on your machine, change the "bundle identifier" in line 18. "com.example.fake2" with a different identifier and you will trigger the notification permission prompt.
The notification example (code pasted below for convenience) doesn’t produce any notification under OSX 14.
OS details (
uname -a
):Code: