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.
pip install pyobjc-framework-usernotificationsuiVerified import paths — ran on the pinned version, not inferred.
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.
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).
Review custom Objective-C subclasses and initializer method implementations for correct reference counting behavior under PyObjC 11.1+ ARC rules.
Avoid subclassing `NSString` or `NSMutableString` directly in Python. Use existing methods or create helper functions/classes that wrap `NSString` instances instead.
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.
Ensure your development and deployment environment is macOS.