Sam Spencer
Sam Spencer

Reputation: 8609

Edit Passbook Pass (.pkpass) file at Runtime?

I know how to make a .pkpass file using tools on my Mac and then zipping them up and signing them (using the signpass tool), but how could I edit the file during runtime in an iOS app?

I realize that in the Apple documentation, they want you to use a server for any pass updates / edits, but this is not what I am aiming to do (I realize the security issues there, and that is not the focus of this question).

How can I do this (I'm not asking for code)? In the documentation, this is the only mention (that I've seen) of actually manipulating the passes at runtime:

In a production environment, the signing and compressing would be part of the system that generates passes.

Any ideas on how this can be done? Are there any third party APIs that allow for this (I've checked out Passdock and Passsource, but Passdock doesn't have an Obj-C API and Passource isn't too clear).

Upvotes: 4

Views: 7919

Answers (2)

ohmi
ohmi

Reputation: 652

As you already have said, Apple does not want you to create your own .pkpass files in an ios App. It is certainly possible to do so, Apple can't NOT allow you to include or fetch certificates although they can certainly reject your app if they want to.

You can adapt code from any number of articles/tutorials to build the various files, create the signature (probably the most arcane and difficult part), and create a .pkpass file in your app. Some of the code in the signpass app is probably reusable as is, if the frameworks it relies on are in the iPhone SDK.

Perhaps you could look at some the services that are already out there that offer pass generation with a high-level API that could be consumed from the phone. This one, for example, which I present with no warranty or endorsement.

Upvotes: 3

WDUK
WDUK

Reputation: 19030

You won't be able to edit the .pkpass file, as it has been signed. If you change it, the signature will be invalid.

The only editing you can do is pre-pkpass generation. If you can create .pkpass files at runtime, you can edit them before signing. Otherwise, the only other option to edit them post generation using push notifications, but that only allows editing of particular fields.

Upvotes: 2

Related Questions