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 : ViewOverview
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
init(_:cardholderName:passStyle:primaryAccountSuffix:cardDetails:description:filters:onRequest:onCompletion:)init(_:cardholderName:passStyle:primaryAccountSuffix:cardDetails:description:filters:onRequest:onCompletion:fallback:)init(_:onCompletion:)init(_:onCompletion:)init(_:onCompletion:fallback:)init(_:onCompletion:fallback:)init(_:onRequest:onCompletion:)init(_:onRequest:onCompletion:fallback:)init(_:primaryAccountSuffix:passStyle:cardDetails:description:filters:onRequest:onCompletion:)init(_:primaryAccountSuffix:passStyle:cardDetails:description:filters:onRequest:onCompletion:fallback:)init(action:)init(carKeyPassword:supportedRadioTechnologies:issuerIdentifier:onCompletion:)init(carKeyPassword:supportedRadioTechnologies:issuerIdentifier:onCompletion:fallback:)