{"id":6187,"library":"pyobjc-framework-usernotificationsui","title":"User Notifications UI Framework (PyObjC)","description":"PyObjC is a bridge between Python and Objective-C, allowing Python scripts to use and extend existing Objective-C class libraries, including Cocoa frameworks on macOS. The `pyobjc-framework-usernotificationsui` package provides Python wrappers for the macOS UserNotificationsUI framework. This framework enables developers to customize the appearance and interactivity of local and remote notifications by adding a notification content app extension to their macOS applications. The current version is 12.1, and PyObjC generally follows an annual release cadence, typically in October.","status":"active","version":"12.1","language":"python","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","cocoa","ui","notifications","app extension"],"install":[{"cmd":"pip install pyobjc-framework-usernotificationsui","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"The core PyObjC bridge is required for all framework wrappers.","package":"pyobjc-core","optional":false}],"imports":[{"note":"Classes within PyObjC framework wrappers are typically imported directly from the top-level framework package.","symbol":"UNNotificationContentExtension","correct":"from UserNotificationsUI import UNNotificationContentExtension"},{"note":"Core notification objects like UNNotification are part of the Foundation framework, not UserNotificationsUI.","symbol":"UNNotification","correct":"from Foundation import UNNotification"},{"note":"Notification Content Extensions are subclasses of NSViewController, which is part of the AppKit framework.","symbol":"NSViewController","correct":"from AppKit import NSViewController"}],"quickstart":{"code":"import objc\nfrom AppKit import NSViewController\nfrom Foundation import NSObject, NSLog, UNNotification\nfrom UserNotificationsUI import UNNotificationContentExtension\n\nclass MyNotificationViewController (NSObject, NSViewController, UNNotificationContentExtension):\n    \"\"\"\n    This class defines a custom view controller for a rich notification.\n    It runs as part of a macOS Notification Content Extension.\n    This code is illustrative and not directly runnable as a standalone script.\n    It requires an Xcode project with a Notification Content Extension target\n    configured to use this Python class as its principal class.\n    \"\"\"\n\n    # @objc.IBOutlet('myLabel') # Example if using a NIB/Storyboard\n    # myLabel = objc.ivar.IBOutlet()\n\n    def viewDidLoad(self):\n        super().viewDidLoad()\n        NSLog(\"MyNotificationViewController: viewDidLoad called!\")\n        # Access your UI elements here, if loaded from NIB/Storyboard\n        # if self.myLabel:\n        #    self.myLabel.setStringValue_(\"Hello from PyObjC notification!\")\n\n    def didReceiveNotification_(self, notification: UNNotification):\n        \"\"\"\n        Called when a new notification arrives for the extension to display.\n        \"\"\"\n        content = notification.request().content()\n        NSLog(f\"Received notification with title: {content.title()}, body: {content.body()}\")\n        # Update your custom UI elements based on the notification content\n        # if self.myLabel:\n        #    self.myLabel.setStringValue_(content.body())\n\n    def didReceiveNotificationResponse_completionHandler_(self, response, completionHandler):\n        \"\"\"\n        Called when the user interacts with your custom notification UI (e.g., clicks a button).\n        \"\"\"\n        NSLog(f\"Received response for action: {response.actionIdentifier()} with text: {response.userText()}\")\n        # Perform actions based on user interaction\n        completionHandler(UNNotificationContentExtension.UNNotificationContentExtensionResponseOptionDoNotDismiss)\n\n# To integrate this, you would typically build a macOS application with py2app\n# and include a Notification Content Extension target in Xcode that points to\n# this Python code as its principal class.","lang":"python","description":"This quickstart demonstrates the basic structure for a Python class using `pyobjc-framework-usernotificationsui` to define a custom notification content extension. This framework is specifically for customizing the *appearance* and *interactivity* of notifications within a dedicated app extension, not for sending notifications. The code must be integrated into a macOS app extension project, typically set up via Xcode, where this Python class would act as the `UNNotificationContentExtension`'s view controller. It cannot be run as a standalone script."},"warnings":[{"fix":"Upgrade Python to 3.10 or later, or pin `pyobjc` and `pyobjc-core` to a compatible version (e.g., `pyobjc<12` for Python 3.9, `pyobjc<11` for Python 3.8).","message":"PyObjC v12.0 dropped support for Python 3.9, and v11.0 dropped support for Python 3.8. Users on older Python versions must use an older PyObjC release.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review custom Objective-C subclasses and initializer method implementations for correct reference counting behavior under PyObjC 11.1+ ARC rules.","message":"The behavior of initializer methods (methods in the 'init' family) was changed in PyObjC v11.1 to align with `clang`'s Automatic Reference Counting (ARC) documentation. Such methods now correctly 'steal' a reference to `self` and return a new reference. This may affect custom memory management or subclassing patterns if not accounted for.","severity":"breaking","affected_versions":">=11.1"},{"fix":"Avoid subclassing `NSString` or `NSMutableString` directly in Python. Use existing methods or create helper functions/classes that wrap `NSString` instances instead.","message":"Subclassing `NSString` or `NSMutableString` in Python is not supported and will lead to crashes. These classes are marked as 'final' in PyObjC due to their special handling in the bridge.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For sending notifications, use the `pyobjc-framework-usernotifications` package (import `UserNotifications`). For custom UI display of those notifications, use `pyobjc-framework-usernotificationsui` within an app extension.","message":"The `pyobjc-framework-usernotificationsui` library is specifically for customizing the *user interface* of notifications within a macOS app extension (a `UNNotificationContentExtension`). It does *not* provide functionality for sending or scheduling notifications; that is handled by the `UserNotifications` framework.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your development and deployment environment is macOS.","message":"PyObjC is a macOS-only library and will not function on other operating systems like Windows or Linux.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'12.1':78 'ad':64 'allow':16 'annual':84 'app':68,94 'appear':55 'applic':73 'bridg':9 'c':15,26 'cadenc':86 'class':27 'cocoa':30,91 'content':67 'current':75 'custom':53 'develop':51 'enabl':50 'exist':23 'extend':22 'extens':69,95 'follow':82 'framework':4,31,37,47,49 'general':81 'includ':29 'interact':57 'librari':28 'local':59 'maco':33,45,72,90 'notif':2,62,66,93 'object':14,25 'objective-c':13,24 'octob':89 'packag':39 'provid':40 'pyobjc':5,6,36,80 'pyobjc-framework-usernotificationsui':35 'python':11,17,41 'releas':85 'remot':61 'script':18 'typic':87 'ui':3,92 'use':20 'user':1 'usernotificationsui':38,46 'version':76 'wrapper':42","created_at":"2026-04-14T18:45:45.720348+00:00","updated_at":"2026-04-16T19:35:09.370736+00:00","problems":{"verify_error":"× Failed to build `pyobjc-framework-usernotifications==12.2.1`\n  ├─▶ The build backend returned an error\n  ╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)\n\n      [stderr]\n      Traceback (most recent call last):\n        File \"<string>\", line 14, in <module>\n        File\n     "},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"12.2","cli_name":"","cli_version":null,"type":"library","homepage":"https://pyobjc.org","github":"https://github.com/ronaldoussoren/pyobjc","docs":"https://pyobjc.readthedocs.io/en/latest/","changelog":null,"pypi":"https://pypi.org/project/pyobjc-framework-usernotificationsui/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["crm-productivity","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}