2014-12-06 56 views
1

我有三重檢查證書,似乎我的問題可能在於通過php-passbook庫輸出的格式。拴當經由控制檯我的pkpass文件無法正常工作。相信它是相關的字段

錯誤消息:

Dec 6 09:27:33 JOHNs-iPhone MobileSafari[972] <Warning>: Invalid data error reading pass PASS-TYPE-IDENTIFIER/6731247236. The passTypeIdentifier or teamIdentifier provided may not match your certificate, or the certificate trust chain could not be verified. 
Dec 6 09:27:33 JOHNs-iPhone MobileSafari[972] <Warning>: PassBook Pass download failed: The pass cannot be read because it isn’t valid. 

實現:

// Create an event ticket 
    $pass = new EventTicket($event['Order']['transaction_id'], $event['Event']['EventDetail']['visible_name']); 
    $pass->setBackgroundColor('rgb(60, 65, 76)'); 
    $pass->setLogoText('LOGO'); 

    // Create pass structure 
    $structure = new Structure(); 

    // Add primary field 
    $primary = new Field('event', $event['Event']['EventDetail']['visible_name']); 
    $primary->setLabel('Event'); 
    $structure->addPrimaryField($primary); 

    // Add secondary field 
    $secondary = new Field('location', 'LOCATION'); 
    $secondary->setLabel('Location'); 
    $structure->addSecondaryField($secondary); 

    // Add auxiliary field 
    $auxiliary = new Field('datetime', '2015-01-27 @10:25'); 
    $auxiliary->setLabel('Date & Time'); 
    $structure->addAuxiliaryField($auxiliary); 



    // Add icon image 
    $icon = new Image(APP . 'webroot' . DS . '/img/logo_growtix_admin_lg.png', 'icon'); 
    $pass->addImage($icon); 

    // Set pass structure 
    $pass->setStructure($structure); 

    // Add barcode 
    $barcode = new Barcode(Barcode::TYPE_QR, $key); 
    $pass->setBarcode($barcode); 

    // Create pass factory instance 
    $factory = new PassFactory('PASS-TYPE-IDENTIFIER', 'TEAM-IDENTIFIER', 'ORGANIZATION-NAME', APP . 'Vendor' . DS . 'Passbook/certs/PASS.p12', '', APP . 'Vendor' . DS . 'Passbook/certs/AppleWWDRCA.pem'); 
    $factory->setOutputPath(APP . 'webroot/passbook_passes' . DS); 
    $factory->package($pass); 

    $this->redirect('/passbook_passes/'.$event['Order']['transaction_id'].'.pkpass'); 

並將所得JSON:

{ 
"eventTicket": { 
    "primaryFields": [ 
     { 
      "key": "event", 
      "value": "Event Name", 
      "label": "Event" 
     } 
    ], 
    "secondaryFields": [ 
     { 
      "key": "location", 
      "value": "The Salt Palace", 
      "label": "Location" 
     } 
    ], 
    "auxiliaryFields": [ 
     { 
      "key": "datetime", 
      "value": "2015-12-08T13:00-08:00", 
      "label": "Date & Time" 
     } 
    ] 
}, 
"serialNumber": "6731247236_5069_1913", 
"description": "Test", 
"formatVersion": 1, 
"barcode": { 
    "format": "PKBarcodeFormatQR", 
    "message": "test", 
    "messageEncoding": "iso-8859-1" 
}, 
"backgroundColor": "rgb(60, 65, 76)", 
"logoText": "GrowTix", 
"passTypeIdentifier": "PASS-TYPE-IDENTIFIER", 
"teamIdentifier": "TEAM-IDENTIFIER", 
"organizationName": "ORGANIZATION-NAME" 
} 
+0

是否使用PASS-TYPE-標識符和團隊標識符您的通行證?如果是這樣,這將導致錯誤消息。你有一個簽名問題。 teamIdentifier和passTypeIdentifier必須與您用於簽署通行證的證書相匹配。 – PassKit 2014-12-06 17:05:42

+0

我將在此示例代碼:http://eymengunay.github.io/php-passbook/ - 它包括兩個?我感謝任何幫助,它打我發佈後,因爲日誌明確聲明它是一個問題..我的壞。 – 2014-12-06 17:43:52

+0

看到我的答案。您需要更改這兩個字段的值以符合您的證書。 – PassKit 2014-12-06 17:47:28

回答

1

的問題是由於passTypeIdentifierteamIdentifier鍵。

日誌中的這一行顯示您正在使用'PASS-TYPE-IDENTIFIER'作爲您的passTypeIdentifier密鑰。

Dec 6 09:27:33 JOHNs-iPhone MobileSafari[972] <Warning>: Invalid data error reading pass PASS-TYPE-IDENTIFIER/6731247236. The passTypeIdentifier or teamIdentifier provided may not match your certificate, or the certificate trust chain could not be verified. 

您應該使用證書通過類型ID,例如, pass.com.passkit.admin作爲您的passType標識符。這需要與證書上顯示的通行證類型ID /用戶ID相匹配。

您的teamIdentifier需要與證書中的組織單位相匹配。例如。 U4LNY2SS5N

如果您使用Mac,可以使用Finder中的快速預覽(空格鍵)查看這些詳細信息。

enter image description here

+0

謝謝 - 幫了大忙! – 2014-12-06 17:56:08

相關問題