【问题标题】:PKPass error "The pass cannot be read because it isn’t valid."PKPass 错误“无法读取通行证,因为它无效。”
【发布时间】:2017-12-01 11:31:14
【问题描述】:

得到错误

BOM 无法提取存档:无法读取 PKZip 签名

Error Optional(Error Domain=PKPassKitErrorDomain Code=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"
            }
          ]
        }
      }

提前致谢

【问题讨论】:

  • 你有没有试过下载PKPASS文件直接解压,只是为了检查文件是否压缩打包正确?
  • 您是否采用了 PKPass 格式并将其编译为签名、压缩的 .pkpass 包?您传递给 PKPass 函数的数据应该是一个传递包(它是一个扩展名为 .pkpass 的 zip 文件)
  • 是的,我会@PassKit

标签: ios iphone swift swift3 passbook


【解决方案1】:

我曾在 PKPass 上工作过,但遇到了另一个问题。但我在这里提到了通过拉刷新和推送通知生成通行证和更新通行证的所有步骤。 steps...

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 2019-04-18
    • 2012-06-17
    • 1970-01-01
    相关资源
    最近更新 更多