-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'NoneType' object has no attribute 'setDelegate_' #8
Comments
Exact same error, Python 3.10.10 (conda), macOS 13.4. |
I googled quite briefly and as the README suggests, the current method of using NSUserNotificationCenter is deprecated and only supported up to MacOS 11.0, see here. The new way to do it is via UNUserNotificationCenter, but it seems that it is only available when run from a signed binary (?) I just tried myself to get UNUserNotificationCenter to work but it's a mess and hard to get working lol |
I have figured out a way to send notifications, but it's not pretty at all and goes against the point of this library, which is "mac-notification is a Python library to make it as easy as possible to create interactable notifications." Here's the code though: from Cocoa import NSApplication, NSClassFromString
def main():
center = NSClassFromString("UNUserNotificationCenter")
print(center)
current = center.currentNotificationCenter()
print(current)
if __name__ == "__main__":
main() However, if you just run this from a script, it will crash with the exception pip3 install py2app
echo -e "[tools.py2app.bundle.main]\nscript = "main.py"\nbuild-type = "semi-standalone" > pyproject.toml
py2applet --make-setup main.py
./dist/notif.app/Contents/MacOS/notif This code should give you something like I wonder if Jorricks can find a way to send notifications simper than this, but it seems it's a fundamental problem put on by Apple themselves :( |
Sorry for dropping the ball on this one. Have any of you been able to figure this issue out? |
I have posted all my findings above. As I said, I think it is fundamentally impossible to post notifications from an unsigned app alone. However, if you can launch a signed service in the background once, then you can make it send the notifications for you, kind of like a proxy. Hope my terminology is ok |
Same issure here. |
Sorry for replying this late and thanks for reporting this. I have the feeling this is because of not using the official python binary. If you use a self-compiled Python binary that is not officially signed by an Apple certificate, it will throw this error. Could you try with an official Python binary and report back here? Would you mind giving this a shot @MacHu-GWU and @grhkm21 ? |
Python 3.11.3, "client.create_notification" returns the following error:
Process NotificationProcess-1: Traceback (most recent call last): File "/Users/rutger/.pyenv/versions/3.11.3/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/Users/rutger/.pyenv/versions/3.11.3/lib/python3.11/site-packages/mac_notifications/listener_process.py", line 28, in run notification_sender.create_notification(self.notification_config, self.queue).send() File "/Users/rutger/.pyenv/versions/3.11.3/lib/python3.11/site-packages/mac_notifications/notification_sender.py", line 58, in send NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'setDelegate_'
The text was updated successfully, but these errors were encountered: