我有三重檢查證書,似乎我的問題可能在於通過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"
}
是否使用PASS-TYPE-標識符和團隊標識符您的通行證?如果是這樣,這將導致錯誤消息。你有一個簽名問題。 teamIdentifier和passTypeIdentifier必須與您用於簽署通行證的證書相匹配。 – PassKit 2014-12-06 17:05:42
我將在此示例代碼:http://eymengunay.github.io/php-passbook/ - 它包括兩個?我感謝任何幫助,它打我發佈後,因爲日誌明確聲明它是一個問題..我的壞。 – 2014-12-06 17:43:52
看到我的答案。您需要更改這兩個字段的值以符合您的證書。 – PassKit 2014-12-06 17:47:28