Coder Social home page Coder Social logo

passifier's Introduction

Passifier

Generate Apple Passbook passes in Ruby

Passifier does most of the hard work and will more easily allow you to automate generating pkpass files. You simply supply

  • A Hash of metadata and layout (the contents of pass.json for those experienced)
  • Image URLs and paths
  • The location of your key and certificate .pem files
  • Output path where you'd like the generated .pkpass file

Installation

Add this line to your application's Gemfile:

gem 'passifier'

Usage

Metadata and Layout

First, supply a bunch of pass information and styling. This will become the file pass.json within the pass archive. More information on pass.json and creating a layout can be found at developers.apple.com.

serial_number = "SO_SERIAL"

spec = {
  "formatVersion": 1,
  "passTypeIdentifier": "pass.example.example",
  "teamIdentifier": "METS",
  "relevantDate": "2012-07-30T14:19Z",          
  "organizationName": "Example Inc.",
  "serialNumber": serial_number,
  "description": "The example pass from README.md",
  "labelColor": "rgb(122, 16, 38)",
  "backgroundColor": "rgb(227, 227, 227)",
  "foregroundColor": "rgb(110,110,110)",
  "generic": {
    "headerFields": [
      {
        "key": "date",
        "label": "Date",
        "value": "October 30th"
      }
    ],
    "primaryFields": [
      {
        "key": "title",
        "label": "",
        "value": "Passifier!"
      }
    ],
    "secondaryFields": [
      {
        "key": "host",
        "label": "Host",
        "value": "paperlesspost.com",
      }
    ]
  }
}

Images

Specify a Hash of images. Notice that you can use either paths or urls here.

assets = {
  "background.png": "assets/background.png",
  "[email protected]": "assets/[email protected]",
  "icon.png": "assets/icon.png",
  "[email protected]": "assets/[email protected]",
  "logo.png": "http://i.imgur.com/WLUf6.png",
  "[email protected]": "http://i.imgur.com/mOpQo.png",
  "thumbnail.png": "assets/thumbnail.png",
  "[email protected]": "assets/[email protected]"
}

Signing

Give Passifier some info about your .pem files.

(to-do: more info on obtaining certificates and creating pem files)

key_pem = "path/to/a/key.pem"
pass_phrase = "somethingsomething"
cert_pem = "path/to/a/certificate.pem"

# Create a Signing object
signing = Passifier::Signing.new(key_pem, pass_phrase, cert_pem)

Generate!

Now it's time to create your pass.

Passifier::Pass.generate("readme.pkpass", serial_number, spec, assets, signing)

Passifier will have created the file readme.pkpass for you. When opened in Passbook, that pass looks something like:

image

Further Reading

  • Find a similar example with some more explanation here
  • Read a blog post about Passifier here

Documentation

Contributing to Passifier

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Create an issue in the issue tracker
  • Fork the project.
  • Start a feature/bugfix branch; include the issue number in the branch name.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.

Copyright

Copyright © 2012 Paperless Post. See LICENSE.md for details.

passifier's People

Contributors

arirusso avatar georgschlenkhoff avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.