I am attempting to get PKAddPasses to work on SwiftUI and have exahusted all effort, I am starting to think its impossible, the code so far I am able to get the add pass screen to show up and when pressing "Add" the pass gets added to the Wallet however neither the "Add" or "Cancel" button make the view disappear.
struct PassKit: UIViewControllerRepresentable {
var pass: PKPass
func makeUIViewController(context: Context) -> PKAddPassesViewController {
let passvc = PKAddPassesViewController(pass: self.pass)
return passvc!
}
func updateUIViewController(_ uiViewController: PKAddPassesViewController, context: Context) {
}
}
passing a PKPass to the pass varible successfully gets the screen to appear however my struggle is getting it to disappear i have tried this as a last ditch resort
struct PassKit: UIViewControllerRepresentable {
@Binding var done: Bool
var pass: PKPass
class Coordinator: NSObject, PKAddPassesViewControllerDelegate {
var parent: PassKit
init(_ parent: PassKit) {
self.parent = parent
}
func addPassesViewControllerDidFinish(_ controller: PKAddPassesViewController) {
parent.done = false
}
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIViewController(context: Context) -> PKAddPassesViewController {
let passvc = PKAddPassesViewController(pass: self.pass)
passvc?.delegate = context.coordinator
return passvc!
}
func updateUIViewController(_ uiViewController: PKAddPassesViewController, context: Context) {
}
}
the idea would be to bind the done bool and when the its true it would trigger
NavigationLink(
destination:
PassKit(done: self.$PassKitDone.onChange({ done in
self.PassKitPresent = false
}))
.ignoresSafeArea()
.navigationBarHidden(true),
isActive: $PassKitPresent,
label: {})
this swifui code to to go back on the navigation link.
Please can someone help really do need to get this working