For try! Swift NYC, we are playing with the idea of adding QR codes to conference badges that will add attendee’s contact information business card to your Wallet app. It is easy to generate a QR code from a URL. And it is relatively easy to create a PassKit Pass – it’s basically just a bunch of files in a folder. But I was super confused on that step in-between – how do I create a link from the final Passkit .pkpass file…
The Distributing Passes instructions include the following information about this:
So what the hell is a MIME type?!!! I have no idea. But googling around for it, I learned that I couldn’t set it for my jekyll website. I needed another solution!
So after the initial panic and confusion, I took a breath and stepped back. I realized that .pkpass is simply a file. All that was needed was a link to this file (and that MIME type thing, but I chose to ignore it at that moment). Immediately, my thoughts went to Amazon Services, with S3 as the perfect file storage solution.
So I signed-in and created the tryswiftpasskit bucket. I set the location to US East (N. Virginia), since the conference would take place in New York, so that’s the closest.
I went through the rest of the bucket creation process and finished. I then went inside my bucket and clicked the Upload button. I downloaded the Sample Passes listed in their tutorial, so I had one ready to test!
I set the permissions to public, since the link has to be public in order to get the .pkpass file to download into the Wallet app:
And now the magical part… remember that whole MIME type thing?!! From googling around, I figured out enough to set is as the Content-Type property on the file:
It should be set to application/vnd.apple.pkpass. Save and finish and you’re ready to go!
The final step is to get that link. Click into the object in your bucket, and you’ll see it right there for you:
That’s it! Open that link in Safari or via the Mail app (or generate a QR Code) and you’ll see the pass 💃🏻