php-pkpass
php-pkpass copied to clipboard
Chrome IOS generate pass twice
Hello, On google chrome IOS, when I click on the button to download my pass, the link is submitted twice.
My php function to generate the pass :
/**
* @Route("/generate", methods={"GET"}, name="pkpass_generate")
**/
public function generatePass(){
// other treatment
$this->log('inf', 'START GENERATE PASS', 'uop');
$file = $pass->create(false);
$response = new Response();
$response->setContent($file);
$response->headers->add([
'Content-Type'=> 'application/vnd.apple.pkpass',
'Content-Description'=>'File Transfer',
'Content-Transfer-Encoding' => 'binary',
'Connection'=>'Keep-Alive',
'Expires' => '0',
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Last-Modified' => gmdate('D, d M Y H:i:s T'),
'Pragma' => 'public',
'Content-Disposition'=> $disposition
]);
return $response;
}
my view with the button :
<div class="container">
<a class="add_wallet" href="{{ downloadUrl }}" alt="Download pass">a
<img class="img-fluid" src="{{ asset('build/images/add_to_apple_wallet_' ~ app.request.locale ~ '.png') }}" alt="Add to wallet icon" />
</a>
</div>
When I click on the button, according to my logs, I have two calls that are made, I have the print that makes the creation of a first pass, then a second on the second call and it is the one that is downloaded.
2022-02-23 16:22:23 - START GENERATE PASS
2022-02-23 16:22:26 - START GENERATE PASS
Strangely, on safari IOS, I have only one call.
I tried to do a create->(true) as well, but I have the same behavior.
I also tried to use a form with the "get" method but same problem
I'm using the symfony framework in its 4.4 version for information.
Do you have an idea ?
I think this might be a CORS preflight request perhaps? Or some request Chrome does to figure out the content type?
I don't think this is related to this library.
No I don't think it's the "CORS preflight" because when I log the request method, it's two GET methods.
It's from the moment I have "'Content-Type'=>'application/vnd.apple.pkpass'" that it reopens the link and goes back to my function.
Looks like this might be just how Chrome has implemented their PKPass support. Not really a problem that it does two requests though, is it?
No, it's not two requests. I checked first thinking that the button was submitted twice, but no.
I have the impression that chrome sends the information to the IOS system with the url when it detects "'Content-Type'=>'application/vnd.apple.pkpass'" in return and then it opens a kind of webView with this url so that it can be interpreted... I don't know...
Indeed it's not linked with the library but it's a behavior linked to the pass download. I was hoping that someone already had this problem.