{"library":"pyobjc-framework-usernotifications","title":"PyObjC UserNotifications Framework","description":"PyObjC is a bridge between Python and Objective-C, allowing full-featured macOS applications and scripts to be written in Python. The `pyobjc-framework-usernotifications` package provides Python wrappers for the macOS UserNotifications framework, enabling developers to send and manage user notifications on macOS. The current version is 12.1, and PyObjC generally follows a release cadence tied to macOS SDK updates and Python version support.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-usernotifications"],"cli":null},"imports":["from UserNotifications import *","from Foundation import *"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import objc\nfrom Foundation import *\nfrom UserNotifications import *\n\ndef send_test_notification():\n    center = UNUserNotificationCenter.currentNotificationCenter()\n\n    # Request authorization for alerts, sounds, and badges\n    options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge\n    # The completionHandler can be None for simple cases if no Python callback is needed.\n    granted, error = center.requestAuthorizationWithOptions_completionHandler_(options, None)\n    \n    if error:\n        print(f\"Error requesting authorization: {error.localizedDescription()}\") # cite: 11\n        return\n    \n    if not granted:\n        print(\"Notification authorization denied. Please enable in System Settings -> Notifications -> Python.\") # cite: 11\n        return\n\n    # Create notification content\n    content = UNMutableNotificationContent.alloc().init()\n    content.setTitle_(\"PyObjC Notification\")\n    content.setBody_(\"This is a test notification from your Python script!\")\n    content.setSound_(UNNotificationSound.defaultSound())\n    content.setUserInfo_({\"source\": \"PyObjC\"}) # Optional: Add custom data\n\n    # Create a trigger for immediate delivery (1 second from now, no repeat)\n    trigger = UNTimeIntervalNotificationTrigger.triggerWithTimeInterval_repeats_(1, False)\n\n    # Create the request with a unique identifier, content, and trigger\n    request = UNNotificationRequest.requestWithIdentifier_content_trigger_(\"pyobjcTestNotification\", content, trigger)\n\n    # Add the request to the notification center\n    center.addNotificationRequest_withCompletionHandler_(request, None)\n    print(\"Notification request added. Check your macOS Notification Center.\")\n\n    # Keep the Python process alive briefly to allow the notification to be processed by macOS.\n    # In a full macOS application, you would typically run an NSApplication main loop.\n    NSRunLoop.currentRunLoop().runUntilDate_(NSDate.dateWithTimeIntervalSinceNow_(3.0))\n    print(\"Script finished. Notification should appear shortly if authorized.\")\n\nif __name__ == \"__main__\":\n    send_test_notification()\n","lang":"python","description":"This quickstart demonstrates how to send a simple user notification using `pyobjc-framework-usernotifications`. It requests notification authorization, creates notification content and a trigger, and then schedules the notification. The script uses `NSRunLoop` to keep the Python process alive briefly, allowing macOS to process and display the notification. For persistent applications, a full `NSApplication` run loop would be required.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.8,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-usernotifications","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.5,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}