2016-08-05 3 views
0

passgenerator 라이브러리를 사용하여 iPhone의 Apple Wallet에 설치된 .pkpass을 생성합니다. .pkpass 파일이 성공적으로 생성되었지만 iPhone의 "wallet"에 추가 할 수 없기 때문에 전자 메일 첨부 파일에서이 파일을 열려고해도 오류가 표시되지 않습니다. Mac에서 "Pass Viewer"로 열면 바코드 영역에 오류가 표시됩니다. 다음은 스크린 샷입니다. 내가 뭔가 잘못하고있는 중이 야 어디PHP에서 생성 된 패스가 iPhone의 지갑에 설치되지 않았습니다.

coupon

모르겠어요. 나는 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; 
    } 

정말 도움이 될만한 도움이 될 것입니다. 구성이나 다른 곳에서 잘못된 일을하는 경우 알려주십시오.

+0

Xcode 로그 란 무엇입니까? Mac 또는 Xcode가 없으면 .pkapss 번들에 대한 링크를 게시 할 수 있습니까? JSON에 만료 날짜가 설정되지 않았으므로 패스 유형 ID 인증서가 만료되었거나 취소되었으므로 바코드가 회색으로 표시됩니다. – PassKit

+0

또한 보조 레이블에 빈 문자열이 있습니다. 해당 키를 제거하거나 공백을 추가하십시오. null 문자열은 오류를 발생시킵니다. – PassKit

+0

@PassKit 보조 필드를 변경했지만 아무런 영향을주지 않습니다. 패스 패키지 이메일을 보내드릴 수 있도록 이메일 주소를 제공해 주시겠습니까? –

답변

1

서명에 문제가 있습니다.

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.pngthumbnail.png은 쿠폰 형식 전달에 유효한 이미지가 아니므로 삭제할 수 있습니다.

+0

@PassKit에 감사드립니다. 당신은 생명의 은인입니다. 제발 디버깅을 위해했던 것처럼이 로그를 어떻게 확인할 수 있습니까? –

+1

iPhone, Mac 및 Xcode가 필요합니다. iPhone을 Mac에 연결 한 다음 Xcode에서 Window-> Devices를 선택한 다음 장치를 선택하십시오. 로그는 하단 창에 출력됩니다. – PassKit