I am implementing Apple Wallet, where I need to add the card to the wallet. I am trying to convert the certificates, nonce and nonceSignature that I am receiving in the addPaymentPassViewController(_:generateRequestWithCertificateChain:nonce:nonceSignature:completionHandler:) delegate method of PKAddPaymentPassViewControllerDelegate of PassKit, from 'Data' to String encoded in 'UTF8' format.
However, the conversion returns nil while converting from Data to String using utf8 encoding format.
Pls find an image attached. I have highlighted where the conversion fails
Could any please help me to identify what is going wrong?
However, the conversion returns nil while converting from Data to String using utf8 encoding format.
Pls find an image attached. I have highlighted where the conversion fails
Could any please help me to identify what is going wrong?
Code Block class ViewController: PKAddPaymentPassViewControllerDelegate { func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void) { var encodedCertificateString = "" for index in 0..<certificates.count { if let encodedCertString = String(data: certificates[index], encoding: .utf8) { encodedCertificateString.append(encodedCertString) if index != (certificates.count-1) { encodedCertificateString.append(", ") } } } } func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, didFinishAdding pass: PKPaymentPass?, error: Error?) { controller.dismiss() } }