I'm trying to test a simple Python script to send out a macOS notification:
import UserNotifications
def notif_callback(err):
print("Error in notification callback:",err)
def auth_callback(granted, err):
print("Granted: ",granted,)
print("Error in authorization request: ",err)
content=UserNotifications.UNMutableNotificationContent.alloc().init()
content.setTitle_("Test")
r=UserNotifications.UNNotificationRequest.requestWithIdentifier_content_trigger_('test_notification',content,None)
c=UserNotifications.UNUserNotificationCenter.currentNotificationCenter()
c.requestAuthorizationWithOptions_completionHandler_(0b111111,auth_callback)
c.addNotificationRequest_withCompletionHandler_(r,notif_callback)
However, when I tried to run the program, it gives the following errors
Granted: False
Error in authorization request: Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application}
Error in notification callback: Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application}
I have not seen any notification authorization from my system and it seems the OS automatically denied the request. In the system preferences, Python has been granted all notification permissions. What am I missing here?