Is it possible to read the contents of a PKPass in Swift? I haven't been able to find a way to do this.
What I am doing:
- I go to the wallet
- I select a boarding pass
- I share the boarding pass to my app
- Using the share extension I try to read the PKPass
The following code gets me the PKPass but I cannot get its' contents:
inputItems.forEach { item in
if let attachments = item.attachments,
!attachments.isEmpty {
attachments.forEach { attachment in
var imageType = "Nothing";
if(attachment.hasItemConformingToTypeIdentifier("com.apple.pkpass")){
imageType = "com.apple.pkpass";
}
attachment.loadItem(forTypeIdentifier: imageType as String){dataPass,error in
if let pkPassData = dataPass as? Data,
let pkPass = try? PKPass(data: pkPassData){
let description = pkPass.description // Any property that reads the contents?
self.logger.log("Sharing a message \(description)")
}
}
}
}
}
So here I am getting the description. But what I want is all of the contents of the boarding pass that was shared with me. Any way I can read this?