我的pkpass文件无法正常工作。相信它与领域有关

时间:2014-12-06 16:28:24

标签: objective-c passbook

我已经对证书进行了三次检查,看来我的问题可能在于php-passbook库输出的格式。

受阻时通过控制台发出错误消息:

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"
}

1 个答案:

答案 0 :(得分:2)

问题是由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