I'm trying to implement Apple Provising ( Add card to the wallet ), but I can figure it out an error on the swift side of my implementation. The issue is the
Swift Compiler Error (Xcode): Type 'AppleMethods' does not conform to protocol 'PKAddPaymentPassViewControllerDelegate'
ppDelegate.swift:89:0 ( Which is when it calls 'extension AppleMethods: PKAddPaymentPassViewControllerDelegate'
Does anyone know how to solve it?
This is my code:
class AppleMethods: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
required public init(coder aDecoder: NSCoder) {
faltalError("init(coder:) has not been implemented")
}
static func isPassKitAvailable() -> Bool {
let result = PKAddPaymentPassViewController.canAddPaymentPass()
return result
}
func initEnrollProcess() {
guard let configuration = PKAddPaymentPassRequestConfiguration(encryptionScheme: .ECC_V2) else {
// self.alert(message: "InApp enrollment configuration fails")
}
configuration.cardholderName = cardDetails["cardHolderName"]!
configuration.primaryAccountSuffix = cardDetails["bankCardNumber"]
configuration.localizedDescription = cardDetails["bankCardName"]
configuration.primaryAccountIdentifier = cardDetails["bankCardPanRefId"]
// configuration.paymentNetwork = .masterCard
guard let enrollViewController = PKAddPaymentPassViewController(requestConfiguration: configuration, delegate: self) else {
// self.alert(message: "InApp entrollment controller configuration fails")
return
}
enrollViewController.modalPresentationStyle = UIModalPresentationStyle.pageSheet;
present(enrollViewController, animated: true, completion: nil)
}
}
extension AppleMethods: PKAddPaymentPassViewControllerDelegate {
func addPaymentPassViewController(
_ controller: PKAddPaymentPassViewController,
generateRequestWithCertificateChain certificates: [Data],
nonce: Data, nonceSignature: Data,
completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void){
let certficateArray = certificates.map { $0.base64EncodedString() }
let interactor = AppleWalletInteractor()
interactor.execute(request: request) { response in
let request = PKAddPaymentPassRequest()
request.activationData = response.activationData
request.ephemeralPublicKey = response.ephemeralPublicKey
request.encryptedPassData = response.encryptedPassData
handler(request)
}
}
// func addPaymentPassViewController(
// _ controller: PKAddPaymentPassViewController,
// )
}
I have seen that could be some typo but I can find anything.
You're getting this error because you haven't implemented
The code below compiles just fine for me in Xcode 15