PHP 生成的通行证未安装在 iPhone 上的钱包中
PHP generated pass is not being installed in wallet on an iPhone
我正在使用这个 passgenerator 库生成一个 .pkpass
,它应该安装在 iPhone 上的苹果钱包上。 .pkpass
文件已成功生成,但无法添加到 iPhone 上的 "wallet",当我尝试从电子邮件附件打开此文件时,它甚至没有显示任何错误。
当我在 mac 上使用 "Pass Viewer" 打开它时,它在条形码区域显示一些错误。这是屏幕截图;
我不知道我哪里做错了。我正在使用 laravel 5.1 并且我已经正确地需要这个包,并且还作为文档要求设置环境变量来设置证书路径。
CERTIFICATE_PATH= './assets/certificates/PassCertificate.p12'
CERTIFICATE_PASS= "mypassword"
WWDR_CERTIFICATE='./assets/certificates/WWDRCA.pem'
这是我的控制器代码,我在其中以 json 格式设置其配置。
public function index(PassGenerator $pass)
{
$pass_identifier = 'testPkPass'; // This, if set, it would allow for retrieval later on of the created Pass
$pkpass = $pass->getPass($pass_identifier);
if (!$pkpass) {
$pkpass = $this->createWalletPass($pass_identifier);
}
$path = storage_path().'/app/passgenerator/'.$pass_identifier.'.pkpass';
return Response::download($path, $pass_identifier.'.pkpass', [
'Content-Transfer-Encoding' => 'binary',
'Content-Description' => 'File Transfer',
'Content-Disposition' => 'attachment; filename="myTestingPass.pkpass"',
'Content-length' => strlen($pkpass),
'Content-Type' => PassGenerator::getPassMimeType(),
'Pragma' => 'no-cache',
]);
}
private function createWalletPass($pass_identifier)
{
$pass = new PassGenerator($pass_identifier);
$pass_definition = [
"description" => "description",
"formatVersion" => 1,
"organizationName" => "Black Book",
"passTypeIdentifier"=> "pass.biz.myIdentifier.coupon",
"serialNumber" => "123456",
"teamIdentifier" => "xyz",
"foregroundColor" => "rgb(255, 255, 255)",
"backgroundColor" => "rgb(44, 49, 51)",
"barcode" => [
"message" => "encodedmessageonQR",
"format" => "PKBarcodeFormatQR",
"altText" => "altextfortheQR",
"messageEncoding"=> "utf-8",
],
"coupon" => [
"headerFields" => [
[
"key" => "header",
"label" => "Value",
"value" => "30%"
]
],
"secondaryFields" => [
[
"key" => "welcome",
"label" => "",
"value" => "Welcome valued customer!"
],
[
"key" => "date",
"label" => "EXPIRES",
"value" => "2016/06/29"
]
],
"backFields" => [
[
"key" => "terms",
"label" => "Terms & Conditions",
"value" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
], [
"key" => "contact",
"label" => "Contact Us",
"value" => "[Contact-us] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco."
],
],
],
];
$pass->setPassDefinition($pass_definition);
// Add assets to the PKPass package
$pass->addAsset(base_path('public/assets/wallet/background.png'));
$pass->addAsset(base_path('public/assets/wallet/thumbnail.png'));
$pass->addAsset(base_path('public/assets/wallet/icon.png'));
$pass->addAsset(base_path('public/assets/wallet/logo.png'));
$pkpass = $pass->create();
return $pkpass;
}
任何帮助将不胜感激。如果我在配置或其他地方做错了什么,请告诉我。
您的签名有问题。
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Notice>: Error evaluating trust: <private>
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Notice>: Signature validation: *** FAILED ***
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Fault>: Invalid data error reading pass <private>. <private>
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Notice>: Invalid data error reading pass <private>. <private>
Aug 5 16:38:36 pfr MobileSafari[2017] <Notice>: PassBook Pass download failed: The pass cannot be read because it isn't valid.
您 pass.json
有一个团队标识符 "teamIdentifier":"5w2h"
根据你的签名文件,你的团队标识符是WY92JHSJ83。修复您的团队标识符,然后重试。
您也可以删除 background.png
和 thumbnail.png
,因为它们不是优惠券格式通行证的有效图像。
我正在使用这个 passgenerator 库生成一个 .pkpass
,它应该安装在 iPhone 上的苹果钱包上。 .pkpass
文件已成功生成,但无法添加到 iPhone 上的 "wallet",当我尝试从电子邮件附件打开此文件时,它甚至没有显示任何错误。
当我在 mac 上使用 "Pass Viewer" 打开它时,它在条形码区域显示一些错误。这是屏幕截图;
我不知道我哪里做错了。我正在使用 laravel 5.1 并且我已经正确地需要这个包,并且还作为文档要求设置环境变量来设置证书路径。
CERTIFICATE_PATH= './assets/certificates/PassCertificate.p12'
CERTIFICATE_PASS= "mypassword"
WWDR_CERTIFICATE='./assets/certificates/WWDRCA.pem'
这是我的控制器代码,我在其中以 json 格式设置其配置。
public function index(PassGenerator $pass)
{
$pass_identifier = 'testPkPass'; // This, if set, it would allow for retrieval later on of the created Pass
$pkpass = $pass->getPass($pass_identifier);
if (!$pkpass) {
$pkpass = $this->createWalletPass($pass_identifier);
}
$path = storage_path().'/app/passgenerator/'.$pass_identifier.'.pkpass';
return Response::download($path, $pass_identifier.'.pkpass', [
'Content-Transfer-Encoding' => 'binary',
'Content-Description' => 'File Transfer',
'Content-Disposition' => 'attachment; filename="myTestingPass.pkpass"',
'Content-length' => strlen($pkpass),
'Content-Type' => PassGenerator::getPassMimeType(),
'Pragma' => 'no-cache',
]);
}
private function createWalletPass($pass_identifier)
{
$pass = new PassGenerator($pass_identifier);
$pass_definition = [
"description" => "description",
"formatVersion" => 1,
"organizationName" => "Black Book",
"passTypeIdentifier"=> "pass.biz.myIdentifier.coupon",
"serialNumber" => "123456",
"teamIdentifier" => "xyz",
"foregroundColor" => "rgb(255, 255, 255)",
"backgroundColor" => "rgb(44, 49, 51)",
"barcode" => [
"message" => "encodedmessageonQR",
"format" => "PKBarcodeFormatQR",
"altText" => "altextfortheQR",
"messageEncoding"=> "utf-8",
],
"coupon" => [
"headerFields" => [
[
"key" => "header",
"label" => "Value",
"value" => "30%"
]
],
"secondaryFields" => [
[
"key" => "welcome",
"label" => "",
"value" => "Welcome valued customer!"
],
[
"key" => "date",
"label" => "EXPIRES",
"value" => "2016/06/29"
]
],
"backFields" => [
[
"key" => "terms",
"label" => "Terms & Conditions",
"value" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
], [
"key" => "contact",
"label" => "Contact Us",
"value" => "[Contact-us] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco."
],
],
],
];
$pass->setPassDefinition($pass_definition);
// Add assets to the PKPass package
$pass->addAsset(base_path('public/assets/wallet/background.png'));
$pass->addAsset(base_path('public/assets/wallet/thumbnail.png'));
$pass->addAsset(base_path('public/assets/wallet/icon.png'));
$pass->addAsset(base_path('public/assets/wallet/logo.png'));
$pkpass = $pass->create();
return $pkpass;
}
任何帮助将不胜感激。如果我在配置或其他地方做错了什么,请告诉我。
您的签名有问题。
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Notice>: Error evaluating trust: <private>
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Notice>: Signature validation: *** FAILED ***
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Fault>: Invalid data error reading pass <private>. <private>
Aug 5 16:38:36 pfr MobileSafari(PassKitCore)[2017] <Notice>: Invalid data error reading pass <private>. <private>
Aug 5 16:38:36 pfr MobileSafari[2017] <Notice>: PassBook Pass download failed: The pass cannot be read because it isn't valid.
您 pass.json
有一个团队标识符 "teamIdentifier":"5w2h"
根据你的签名文件,你的团队标识符是WY92JHSJ83。修复您的团队标识符,然后重试。
您也可以删除 background.png
和 thumbnail.png
,因为它们不是优惠券格式通行证的有效图像。