3

I am writing the server part of a Passbook implementation. The Passbook "card" will be static and not change. Do I really have to use a server to compile the pkpass file?

Reason I ask is that in the sample project Apple has then they have Objective-C code to create and sign a Passbook. If I am only going to use a static card that will not update then I see no point in compiling the pkpass on the server when I can do it locally in the app.

Simon Zettervall
  • 1,764
  • 1
  • 15
  • 31
  • possible duplicate of [can we create a pass (.pkpass file) programatically in Xcode?](http://stackoverflow.com/questions/12852077/can-we-create-a-pass-pkpass-file-programatically-in-xcode) – Wain Aug 12 '13 at 15:53
  • 2
    I don't see it as a duplicate. The question you reference asks how to sign a pass programatically, this question is asking why the pass needs to be signed outside of the app. – PassKit Aug 12 '13 at 16:12

1 Answers1

5

If the pass is truly static, I.e. it does not contain the webServiceURL or authenticationToken keys and does not contain variable data provided by the user, then you do not require a server.

You still need to create and sign the pass, but this can be done with the command line tool that Apple provide.

Once you have your .pkpass bundle, you can either add the signed .pkpass bundle to your app bundle, or post it to a web server or CDN (E.g. Amazon S3). To add it to the users Passbook from within your app, retrieve it from your app bundle or external URL then pass it to a PKAddPassesViewController.

Personally, I would opt for posting the .pkpass bundle somewhere online because it will allow you to change the pass without having to resubmit the app.

Compiling a .pkpass from within an app is a very bad idea. Your app may not be approved because to sign from within your app requires you to embed your Pass Type ID private key within your app bundle.

If you need to incorporate unique user info within a pass, then this will almost certainly require you to build a server, or use a service provider, since every pass will still need to be built and signed to order.

PassKit
  • 12,231
  • 5
  • 57
  • 75
  • I see, thank you for the answer. However, what if I were to save the "Pass Type ID private key" on a server, will Apple then be more favorable to accept the app? – Simon Zettervall Aug 13 '13 at 09:18
  • That may be more acceptable, but then why go to the trouble (and risk) of storing it on the server when it would be just as easy to write a server side script to produce the pass. There's at least half a dozen open source libraries out there. – PassKit Aug 13 '13 at 09:35
  • True, so as I have understood it, even though I do not need a server to update the cards, it is still more feasible to generate them on the server to reduce rejection from Apple and be more secure. – Simon Zettervall Aug 13 '13 at 09:41
  • Yes, precisely. You cannot sign from within your app without risking exposing your private key. – PassKit Aug 13 '13 at 09:45
  • It's also worth noting that if you're generating a pass for yourself, you don't need an app or CDN at all. You can simply use Apple's `signpass` command line tool to generate the pass, and then send yourself the `.pkpass` file via iMessages, Mail, etc. – Senseful Nov 26 '22 at 00:21
  • @PassKit Do you know the names of any of these open source libraries? I'm unable to find tutorials/example code/etc... on how to create and sign passes on a server. Thanks. – Supertecnoboff Jan 25 '23 at 16:34