14

I just created an app and a pass, so I can add the pass to the PassBook in iPod, but I cannot share the pass by email or link from web server. From the documentation I read from Apple, I need to add a MIME type as application/vnd.apple.pkpass. However, I don't understand clearly what steps should I do. I don't know how to use MIME type.

How should I add this MIME type in order to use pass from my web service?

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
malinchhan
  • 767
  • 2
  • 8
  • 28
  • What server are you using (Apache, nginx, IIS?) What language are you using (PHP, C#?) – PassKit Mar 13 '13 at 11:47
  • Server is Apache and I use PHP language. – malinchhan Mar 13 '13 at 14:27
  • Which of the solutions below did you try? – PassKit Mar 14 '13 at 02:35
  • what are the differences between using pure php solution and simple php ? – malinchhan Mar 14 '13 at 03:33
  • No practical difference. The PHP solution I gave doesn't require any server configuration and will always force the file to download. It also prevents the browser from caching the file. You can accomplish the same by configuring Apache. It also adds a `Last-Modified` header, which is used by the iOS device when requesting an updated .pkpass bundle. The 'simple' PHP solution of just adding a `Content-Type` header may not be sufficient to ensure that a .pkpass file downloads each and every time. – PassKit Mar 14 '13 at 03:51
  • your solution works well ! – malinchhan Mar 14 '13 at 04:25

4 Answers4

16

Apache

Add the following line to either:

  • the .htaccess in the directory serving your .pkpass, or
  • to the mime.types file, or
  • to your appache httpd.conf or virtuatl server .conf file

Then restart Apache (not required if adding to .htaccess)

AddType application/vnd.apple.pkpass    pkpass

nginx

Add the following line to your mime.types file and restart nginx

application/vnd.apple.pkpass    pkpass;

IIS

  1. Open IIS Manager and navigate to the level you want to manage.
  2. In Features View, double-click MIME Types.
  3. In the Actions pane, click Add.
  4. In the Add MIME Type .pkpass
  5. Type application.vnd.pkpass n the MIME text box
  6. Click OK
  7. Restart IIS

If you are serving your file via a script and are not able to edit your web server config you could add the following line before any content is sent:

PHP

header('Content-Type: application/vnd.apple.pkpass');

C#

WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/vnd.apple.pkpass");
PassKit
  • 12,231
  • 5
  • 57
  • 75
4

For a pure PHP solution, add your .pkpass bundle to the server, then create the following file and name this file pass.php.

<?php   
$pkpass_file = '/path/to/your/.pkpass/file/GenericMemberCard.pkpass';

header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.apple.pkpass");
header('Content-Disposition: attachment; filename="pass.pkpass"');
clearstatcache();
$filesize = filesize($pkpass_file);
if ($filesize)
    header("Content-Length: ". $filesize);
header('Content-Transfer-Encoding: binary');
if (filemtime($pkpass_file)) {
    date_default_timezone_set("UTC");
    header('Last-Modified: ' . date("D, d M Y H:i:s", filemtime($pkpass_file)) . ' GMT');
}
flush();
readfile($pkpass_file);

Then create a second file linking to the file you created above.

<a href="pass.php">Click to download your pass</a>
PassKit
  • 12,231
  • 5
  • 57
  • 75
  • I am trying the exact same thing but for some reason it always show "safari can not download" in my iphone 4s and 6. It would be great if you can help me with this - I have been trying this since last 1 day and I have an urgent requirement. – Anurag Arya Nov 19 '14 at 11:30
  • Most likely your signature file is incorrect, but it could also be a problem with your pass.json. Turn on Additional Passbook logging from your phone's developer menu, attach your phone to Xcode and review the console output as you attempt to load the pass. This should give you some insight into what is going wrong. – PassKit Nov 21 '14 at 10:38
0

Through Windows 10 IIS

  1. Open IIS Manager and navigate to the level you want to manage.
  2. In Features View, double-click MIME Types.
  3. In the Actions pane, click Add.
  4. In the Add MIME Type .pkpass
  5. Type application.vnd.pkpass n the MIME text box
  6. Click OK
  7. Restart IIS
0

Any one still struggling with IIS. For IIS the suggest types here are wrong IIS expects xx/xxxxxx so this is what the correct one would look like in IIS.

enter image description here

Ricky Gummadi
  • 4,559
  • 2
  • 41
  • 67