{"library":"pyobjc-framework-pushkit","title":"PyObjC PushKit Framework","description":"pyobjc-framework-pushkit provides Python wrappers for the PushKit framework on macOS, allowing Python applications to interact with Apple's PushKit services, such as VoIP push notifications. The library is currently at version 12.1 and typically releases new versions in alignment with macOS SDK updates, often with several releases per year to incorporate new features, bug fixes, and Python version support.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-pushkit"],"cli":null},"imports":["from PushKit import PKPushRegistry","from PushKit import PKPushRegistryDelegate","from PushKit import PKPushTypeVoIP"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import objc\nfrom Foundation import NSObject, NSLog, NSSet\nfrom PushKit import PKPushRegistry, PKPushRegistryDelegate, PKPushTypeVoIP\nfrom PyObjCTools import AppHelper\n\n\nclass PushDelegate(NSObject):\n    # Adopting the PKPushRegistryDelegate protocol\n    def init(self):\n        self = objc.super(PushDelegate, self).init()\n        if self is None:\n            return None\n        NSLog('PushDelegate initialized.')\n        return self\n\n    def pushRegistry_didUpdatePushCredentials_forType_(self, registry, credentials, pushType):\n        NSLog(f'pushRegistry:didUpdatePushCredentials:forType_ called for type: {pushType}, token: {credentials.token()}')\n        # In a real app, send credentials.token() to your server\n        # for APNs registration.\n\n    def pushRegistry_didReceiveIncomingPushWithPayload_forType_completionHandler_(self, registry, payload, pushType, completion):\n        NSLog(f'pushRegistry:didReceiveIncomingPushWithPayload:forType:completionHandler_ called for type: {pushType}, payload: {payload}')\n        # Process the incoming push notification payload.\n        # Call the completion handler when done.\n        completion()\n\n    def pushRegistry_didInvalidatePushTokenForType_error_(self, registry, pushType, error):\n        NSLog(f'pushRegistry:didInvalidatePushTokenForType:error_ called for type: {pushType}, error: {error}')\n\n\ndef main():\n    # Initialize an NSApplication (required for delegate pattern)\n    # For a console app, you might not explicitly use NSApplication.sharedApplication(),\n    # but the runloop expects a Cocoa environment.\n    # from AppKit import NSApplication # Uncomment if you need direct AppKit interaction\n\n    # Create the push registry delegate\n    delegate = PushDelegate.alloc().init()\n\n    # Create a PKPushRegistry object\n    # initWithQueue:nil means callbacks happen on the main thread\n    # PKPushRegistry requires a queue, typically the main queue for UI apps\n    # For a simple console app, we can use nil to imply the main thread's runloop.\n    push_registry = PKPushRegistry.alloc().initWithQueue_(None)\n    push_registry.setDelegate_(delegate)\n\n    # Register for VoIP push notifications\n    push_registry.setDesiredPushTypes_(NSSet.setWithObject_(PKPushTypeVoIP))\n\n    NSLog('PushKit registration initiated. Entering app event loop.')\n    # Run the application's event loop. This is crucial for receiving delegate callbacks.\n    # In a real app, this would be part of the main NSApplication runloop.\n    # For a simple console demonstration, AppHelper.runConsoleEventLoop() is used.\n    try:\n        AppHelper.runConsoleEventLoop(installInterrupt=True)\n    except KeyboardInterrupt:\n        NSLog('Application terminated by user.')\n        AppHelper.stopEventLoop()\n\n\nif __name__ == '__main__':\n    main()\n","lang":"python","description":"This quickstart demonstrates how to initialize `PKPushRegistry` and register for VoIP push notifications using `pyobjc-framework-pushkit`. It defines a delegate class to handle push registration updates and incoming notifications, then starts a console event loop to process these events. This code requires a macOS environment and an application bundle that has PushKit capabilities enabled.","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-pushkit","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-pushkit","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-pushkit","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-pushkit","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"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-pushkit","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-pushkit","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"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-pushkit","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-pushkit","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.5,"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-pushkit","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-pushkit","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}