ios – PKAddPaymentPassViewControllerDelegate implementation issue Swift

I’m new to native iOS coding and Swift, I’m having a hard time trying to work with this PassKit from Apple.

I saw a few examples and they seen to work fine but when I use on my code I keep getting this error:

Could not build the precompiled application for the device. Swift Compiler Error (Xcode): Argument type 'AppleMethodsController.Type' does not conform to expected type 'PKAddPaymentPassViewControllerDelegate' /Users/-/Documents/workspace/front-end/ios/Runner/AppDelegate.swift:80:115

My Class:

class AppleMethodsController: UIViewController {

  required public init(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
    override func viewDidLoad() {

  static func isPassKitAvailable() -> Bool {
    let result = PKAddPaymentPassViewController.canAddPaymentPass()
    return result

  static func initEnrollProcess(cardDetails: CardDetails) {

    guard let configuration = PKAddPaymentPassRequestConfiguration(encryptionScheme: .ECC_V2) else {
        // self.alert(message: "InApp enrollment configuration fails")

    print("InitEnrollProcess iniciated")


    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")

    // enrollViewController.modalPresentationStyle = UIModalPresentationStyle.pageSheet;
    // present(enrollViewController, animated: true, completion: nil)



extension AppleMethodsController: PKAddPaymentPassViewControllerDelegate {

  func addPaymentPassViewController(
    _ controller: PKAddPaymentPassViewController,
    generateRequestWithCertificateChain certificates: [Data],
    nonce: Data, nonceSignature: Data,
    completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void){
      let certificateArray = { $0.base64EncodedString() }
      let request = IssuerRequest(certificates: certificateArray, nonce: nonce.base64EncodedString(), nonceSignature: nonceSignature.base64EncodedString(), bankCardId: "", accessToken: "", encrypUrl: "")
      // let request = IssuerRequest(certificates: certificateArray, nonce: nonce.base64EncodedString(), nonceSignature: nonceSignature.base64EncodedString(), bankCardId: cardDetails["bankCardPanRefId"], accessToken: "", encrypUrl: "")
      let interactor = AppleWalletInteractor()
      interactor.execute(request: request) { response in
        let newRequest =  PKAddPaymentPassRequest()
        newRequest.activationData = Data(base64Encoded: response.activationData)
        newRequest.ephemeralPublicKey = Data(base64Encoded: response.ephemeralPublicKey)
        newRequest.encryptedPassData = Data(base64Encoded: response.encryptedPassData)

    func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, didFinishAdding pass: PKPaymentPass?, error: Error?) {

I have tryed to change my AppleMethodController to inherit PKAddPaymentPasssViewController but it does work,

My enrollViewController keep acusing as a error type and I it says I can’t invoke the method present from my AppleMethodController.

I’m following this guides but I cant figured out what I’m doing wrong.

Does anybody had a similar issue?

Latest articles


Related articles

Leave a reply

Please enter your comment!
Please enter your name here