生成通行证未加载

Generate passes are not loading

我正在创建一个生成 IOS 通行证并通过电子邮件或短信将其发送给用户的 React 应用程序。我正在使用 passbook gem 生成通行证。但是,当我尝试从 IOS 或模拟器打开它们时,钱包会打开,但通行证不会。

我已经检查了设置指导员,没有发现我遗漏的任何内容。

# config/intitalize/passbook.rb
Passbook.configure do |passbook|
  passbook.p12_password = '12345'
  passbook.p12_key = Rails.root.join('certificates/passkey.pem')
  passbook.p12_certificate = Rails.root.join('certificates/passcertificate.pem')
  passbook.wwdc_cert = Rails.root.join('certificates/WWDR.pem')
end

# passes_controller.rb
class PassesController < ApplicationController
  def generate
    user_card = UserCard.find_by_hash_id params[:user_card_id]
    pass = user_card.generate_pass
    send_file pass.path, type: 'application/vnd.apple.pkpass', disposition: 'attachment', filename: "pass.pkpass" 
  end
end

# models/user_card.rb
...
  def generate_pass
    data = {
      formatVersion: 1,
      passTypeIdentifier: "pass.com.example.stampcard",
      serialNumber: "TIC1000000518",
      teamIdentifier: ENV['APPLE_TEAM_ID'],
      organizationName: self.card.organization.name,
      description: self.card.desc,
      barcode: {
        message: self.hash_id,
        format: "PKBarcodeFormatPDF417",
        messageEncoding: "iso-8859-1",
        altText: self.hash_id
      }
    }
    pass = Passbook::PKPass.new data.to_json.to_s
    pass.addFiles ['logo.png', 'logo@2x.png', 'icon.png', 'icon@2x.png']
    pass.file
  end
...

解压pass.pkpass后得到接下来的两个文件加上logo.png |徽标@2x.png | icon.png |图标@2x.png

pass.json

{"formatVersion":1,"passTypeIdentifier":"pass.com.example.pass","serialNumber":"001","teamIdentifier":"KMCYP92B9M","organizationName":"Douglas, Dibbert and Reynolds","description":"facilitate robust solutions","barcode":{"message":"BInPV506nXdH","format":"PKBarcodeFormatPDF417","messageEncoding":"iso-8859-1"},"coupon":{"primaryFields":[{"key":"offer","label":"for you","value":"Free hug"}]}}

manifest.json

{"pass.json":"1292e22d5bea9edc79f37115fa680f7c4452a4ec","logo.png":"50a2b2fa88be143902527556d0cde943ce887028","logo@2x.png":"50a2b2fa88be143902527556d0cde943ce887028","icon.png":"50a2b2fa88be143902527556d0cde943ce887028","icon@2x.png":"50a2b2fa88be143902527556d0cde943ce887028"}

好的,我开始工作了。我知道这不是最令人满意的答案,但我能够通过重新生成证书来解决这个问题。最重要的是,我意识到序列号是错误的,因为我没有使用哈希值