Contents

AddPassToWalletButton

A type that provides a button that enables people to add a new or existing pass to Apple Wallet.

Declaration

@MainActor @preconcurrency struct AddPassToWalletButton<Fallback> where Fallback : View

Overview

Use this structure as the SwiftUI equivalent to PKAddPassButton. For design guidance, see Human Interface Guidelines > Technologies > Wallet.

This example checks for a created pass and displays the Add to Apple Wallet button.

@State private var addedToWallet = false

@ViewBuilder var addPassButton: some View {
    if let pass = createMyPass() {
        AddPassToWalletButton([pass]) { added in
            addedToWallet = added
        }
        .frame(width: 250, height: 50)
        .addPassToWalletButtonStyle(.blackOutline)
    } else {
        // Display a fallback view if no pass exists.
    }
}

Topics

Creating the button

See Also

Common data types