获取错误
BOM无法提取存档:无法读取PKZip签名
错误可选(错误域= PKPassKitErrorDomain代码= 1“通行证 无法阅读,因为它无效。“ UserInfo = {NSUnderlyingError = 0x1570e200 {错误 Domain = PKPassKitErrorDomain Code = 1“(null)”}, NSLocalizedDescription =无法读取传递,因为它不是 有效。})
检查此代码
var myPass : PKPass?
self.myPass = PKPass(data: pageData, error: &errorPass)
这是我的代码
if PKPassLibrary.isPassLibraryAvailable()
{
DispatchQueue.main.async {
do {
let pageData = try Data.init(contentsOf: URL(string: mainURL)!)
var errorPass : NSError?
self.myPass = PKPass(data: pageData, error: &errorPass)
MBProgressHUD.hideAllHUDs(for: self.mainScrollview, animated: true)
if errorPass == nil
{
let passview = PKAddPassesViewController(pass: self.myPass!)
passview.delegate = self
self.present(passview, animated: true, completion: nil)
}
else
{
print("Error \(errorPass)")
}
} catch let e as NSError {
print(e.localizedDescription)
MBProgressHUD.hideAllHUDs(for: self.mainScrollview, animated: true)
self.view.makeToast("Something went wrong with error : \(e.localizedDescription)")
}
}
}
我的PKPass格式是
{
"formatVersion" : 1,
"passTypeIdentifier" : "pass.com.pek.pek",
"serialNumber" : "'.$booking_id.'",
"teamIdentifier" : "ABC00001",
"webServiceURL" : "https://peek.com/ba/pass/",
"authenticationToken" : "kjghadsfgghjgjhfadisfgyfgdsyfuya",
"barcode" : {
"message" : "123456789",
"format" : "PKBarcodeFormatQR",
"messageEncoding" : "iso-8859-1"
},
"organizationName" : "Peek Inc.",
"description" : "Room",
"foregroundColor" : "rgb(255, 255, 255)",
"backgroundColor" : "rgb(0, 200, 83)",
"eventTicket" : {
"primaryFields" : [
{
"key" : "event",
"label" : "Name",
"value" : "'.$restaurant_name.'"
}
],
"secondaryFields" : [
{
"key" : "eventtime",
"label" : "Date",
"value" : "'.$slot_date.'"
}
],
"auxiliaryFields" : [
{
"key" : "bookingid",
"label" : "BOOKING ID",
"value" : "'.$booking_id.'"
},
{
"key" : "noofperson",
"label" : "NO OF TICKETS",
"value" : "'.$no_of_tickets.'",
"textAlignment" : "PKTextAlignmentCenter"
}
]
}
}
先谢谢