PyObjC PassKit Framework

12.1 · active · verified Tue Apr 14

pyobjc-framework-passkit provides Python bindings for Apple's PassKit framework on macOS, enabling Python applications to interact with Wallet passes. It is part of the larger PyObjC project, offering direct access to the native macOS APIs. Version 12.1 is current, with releases typically synchronized with new macOS SDKs and PyObjC core updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `PassKit` framework and check if the PassKit library is available on the current macOS system. It also shows how to get the shared `PKPassLibrary` instance and check if the application has permission to add passes. Note that full interaction with Wallet passes typically requires the Python script to be run within a properly signed macOS application bundle with the necessary entitlements.

import PassKit
import objc

def check_passkit_availability():
    if PassKit.PKPassLibrary.isPassLibraryAvailable():
        print("PassKit library is available on this system.")
        pass_library = PassKit.PKPassLibrary.sharedPassLibrary()
        print(f"Shared Pass Library object: {pass_library}")
        # Note: Interacting with passes (e.g., listing, adding) often requires
        # your Python script to be bundled as a properly signed macOS application
        # with specific entitlements.
        # Attempting to fetch passes in a non-entitled script might result in empty lists or errors.
        
        # Example: Check if the current app is allowed to add passes
        if pass_library.canAddPasses():
            print("This application is authorized to add passes to Wallet.")
        else:
            print("This application is not authorized to add passes to Wallet.")

    else:
        print("PassKit library is not available on this system.")

if __name__ == "__main__":
    check_passkit_availability()

view raw JSON →