frozon / passbook Goto Github PK
View Code? Open in Web Editor NEWPassbook gem let's you create pkpass for passbook iOS 6
License: MIT License
Passbook gem let's you create pkpass for passbook iOS 6
License: MIT License
I am wondering if there is a way to develop a passbook (for local dev environment) without needing the certs from an Apple developer portal
Thanks
Encoding::UndefinedConversionError ("\x9F" from ASCII-8BIT to UTF-8):
Hi,
I make my pass. It's work fine, and I can download it from my web browser. And the content of the pass is OK, manifest, signature, json... . But on IOS 6 Beta 3, Safari say Download Failed. Nothing in the console ...
Any idea ?
My json :
'{
"passTypeIdentifier": "pass.xxxx.yyyy",
"formatVersion": 1,
"organizationName": "Flight Express",
"serialNumber": "123456",
"teamIdentifier": "SAB5MVXXXX",
"backgroundColor": "rgb(107,156,196)",
"logoText": "Flight info",
"description": "Demo pass",
"boardingPass": {
"primaryFields": [
{
"key" : "origin",
"label" : "San Francisco",
"value" : "SFO"
},
{
"key" : "destination",
"label" : "London",
"value" : "LHR"
}
],
"secondaryFields": [
{
"key": "gate",
"label": "Gate",
"value": "F12"
},
{
"key": "date",
"label": "Departure date",
"value": "07/11/2012 10:22"
}
],
"backFields": [
{
"key": "passenger-name",
"label": "Passenger",
"value": "John Appleseed"
}
],
"transitType" : "PKTransitTypeAir"
},
"barcode": {
"format": "PKBarcodeFormatQR",
"message": "Flight-GateF12-ID6643679AH7B",
"messageEncoding": "iso-8859-1"
}
}'
I use ruby 1.9.3 and rails 3.2.6
Is anyone having an issue where the passbook doesn't show up in the lock screen?
Sorry.. feel free to delete this.. wrong project.
in my rails web...
in Gemfile
gem 'passbook', :git => 'git://github.com/frozon/passbook.git'
and works well!
but sinatra... ( I'm beginner in sinatra app dev)
require 'passbook'
require 'active_support/json/encoding'
has error...
no such file to load -- passbook
How can I do fix it??? plz... help me...
I keep getting this error: The pass "pass.pkpass" could not be opened. Below's my code. I've re-done the cert process like 3 times. Not sure where it's failing because the package seems intact.
def show
pass = Pass.find(params[:id])
pass_path = ENV['passes_folder_path'] + "/passes/#{pass.id}"
pass_json = File.read(pass_path + "/pass.json")
pkpass = Passbook::PKPass.new pass_json
files = []
Dir.foreach(pass_path) do |file|
next if file == '.' or file == '..' or file == '.DS_Store'
files << file
end
pkpass.addFiles files
send_data(pkpass, type: 'application/vnd.apple.pkpass', disposition: 'attachment', filename: 'pass.pkpass', status: 201, location: [:api, pass])
end
I hit problems using this Gem with latest JRuby 9.1.8.0 and latest JRuby-OpenSSL.
This monkey-patch may be useful - it addresses a bug in JRuby-OpenSSL (by explicitly passing pk7.data
as a second argument to the write_smime
method), as well as problems with str_debut
and str_end
being in a slightly different format in the JRuby output.
Hope its useful to someone :)
module Passbook
class Signer
# this works around a bug in JRuby-OpenSSL related to writing of SMIME,
# as well as discrepancies in the SMIME output compared to what the
# passbook gem expects by default.
def sign(data)
wwdc = OpenSSL::X509::Certificate.new File.read(wwdc_cert)
pk7 = OpenSSL::PKCS7.sign key_hash[:cert], key_hash[:key], data.to_s, [wwdc], OpenSSL::PKCS7::BINARY | OpenSSL::PKCS7::DETACHED
data = OpenSSL::PKCS7.write_smime pk7, pk7.data
str_debut = "filename=smime.p7s"
data = data[data.index(str_debut)+str_debut.length..data.length-1]
str_end = "\n------"
data = data[0..data.index(str_end)-1]
Base64.decode64(data)
end
end
end
I'm setting my expiration dates in the required rfc3339 format using either:
DateTime.parse(Date.today.to_s).to_s
or
Date.today.strftime(""%Y-%m-%dT%H:%M:%S%:z"")
In the simulator and Safari on a mac, this is yielding correct results. But on an ios7 phone, It's subtracting 1 day from my date for the expiration date. I suspect this is a question for StackOverflow, but was hoping someone here might have seen this before.
This is my site...
http://112.217.211.106:3000/passbook/sample
It works well when MacOS Safari...
but...
iPhone Safari does not print "background.png" ...
plz, help me
I'm Korean User... So my english is very poor... sorry
Removing the call to .close
will fix it. You can't access an instance of Tempfile
after close
is called. Perhaps adding another method like pass.cleanup!
that closes the temp file is a good idea.
Pardon the newb question, but could you detail differences between your tempfile implementaiton vs stream and any impacts to the user experience?
Thanks
S
Ruby 3.2 includes OpenSSL 3. This causes issues signed Passbook passes using a p12
archive.
The fix is to extract the certificate and private key from your p12
file and pass those individually to the Passbook gem.
Passbook.configure do |passbook|
passbook.wwdc_cert = Rails.root.join('config/apple/wwdr.pem')
# no longer works in Ruby 3.2 / OpenSSL 3
# passbook.p12_certificate = Rails.root.join('config/apple/whatever.p12')
# passbook.p12_password = ''
# this works in Ruby 3.2
passbook.p12_certificate = Rails.root.join('config/apple/whatever.crt')
passbook.p12_key = Rails.root.join('config/apple/whatever.key')
end
pk build your_pass_name -w ./wwdc.pem -c ./your_pass_name.p12 -p ''
➜ repo git:(master) ✗ pk build mypass -w ./wwdc.pem -c ./mypass.p12 -p ''
invalid option: -w
Until this gem is on rubygems.org... I have tried in vain to install this but keep failing miserably. There is not even a .gem file, so I try to build the .gem myself by doing
gem build ~/Downloads/passbook-0.0.4/passbook.gemspec
But I get
ERROR: While executing gem ... (Gem::InvalidSpecificationException)
["LICENSE", "README.md"] are not files
Any ideas?
I want to use this gem... in sinatra...
is it possible???
Hi, I've got this error:
Encoding::UndefinedConversionError ("\x9F" from ASCII-8BIT to UTF-8):
passbook = Passbook::PKPass.new json passbook.addFiles [Rails.root.join('certificates/icon.png'), Rails.root.join('certificates/[email protected]')] gen_pass = passbook.file send_file(gen_pass.path, type: 'application/vnd.apple.pkpass', disposition: 'attachment', filename: "pass.pkpass")
What I do wrong?
Rais 6, ruby 2.7.1
Hello All,
I followed below steps:-
Once I start server then facing below error:-
block in <top (required)>': undefined method
p12_cert=' for Passbook:Module (NoMethodError)Thanks! in advance.
Added config.middleware.use Rack::PassbookRack
to application.rb and have gem 'passbook'
in my gemfile. I have added all of my certs to the config file, and when I start the server I get the error message below.
/rails/test_project/config/application.rb:63:in
class:Application': uninitialized constant Rack::PassbookRack (NameError)
from /rails/test_project/config/application.rb:13:in <module:TestProject>' from /rails/test_project/config/application.rb:12:in
<top (required)>'
from /Users/jbadger/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.12/lib/rails/commands.rb:53:in require' from /Users/jbadger/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.12/lib/rails/commands.rb:53:in
block in <top (required)>'
from /Users/jbadger/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.12/lib/rails/commands.rb:50:in tap' from /Users/jbadger/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.12/lib/rails/commands.rb:50:in
<top (required)>'
from script/rails:6:in require' from script/rails:6:in
Are you guys the same ones who do this gem? https://rubygems.org/gems/passbook
I'm seeing this error when I try to download and open a pkpass under iOS 7
Invalid data error reading pass pass.com.domain.discount/2500000.
The passTypeIdentifier or teamIdentifier provided may not match your certificate, or the certificate trust chain could not be verified.
Error adding pass The pass cannot be read because it isn’t valid.
However ,the passTypeIdentifier
and teamIdentifier
seem to be correct since everything works fine under iOS 6 and even Safari from Mavericks.
As far as I can tell, the only difference in the signing process with iOS 7 is that the signature needs to contain a signing date.
My apologies about the noob questions, where can I obtain the notification_cert.pem cert?
Hi,
I made a simple Sinatra app that uses this Gem. It runs fine on localhost, but when I deploy to Heroku I get the error NoMethodError - undefined method 'write_buffer' for Zip::ZipOutputStream:Class:
which is being raised by the line /app/vendor/bundle/ruby/2.0.0/gems/passbook-0.2.1/lib/passbook/pkpass.rb:122:in outputZip
.
Any idea what the cause of this could be?
I posted on StackOverflow with the same problem, more detailed description here
If the formatVersion is not a number then the pkpass does not open in PassBook.
You may want to put an exception for that. My team member working on a pull request.
We've been using this gem for a few years, but suddenly we're unable to open generated .pkpass files and all we've done is generated a new Pass Type certificate from Apple. Has anyone else had any issues lately?
I'm setting up push notifications and I'm getting a no method error for Grocer when calling Passbook::PushNotification.send_notification
➜ wallet git:(62) ✗ rails c
Loading development environment (Rails 4.2.0)
irb: warn: can't alias context from irb_context.
2.2.0 :001 > Passbook::PushNotification.send_notification 'SNIP'
NoMethodError: undefined method `pusher' for Grocer:Module
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/passbook-0.4.1/lib/passbook/push_notification.rb:4:in `send_notification'
from (irb):1
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /Users/jspooner/v/wallet/bin/rails:8:in `<top (required)>'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/commands/rails.rb:6:in `call'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/command_wrapper.rb:38:in `call'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application.rb:183:in `block in serve'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application.rb:156:in `fork'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application.rb:156:in `serve'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application.rb:131:in `block in run'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application.rb:125:in `loop'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application.rb:125:in `run'
from /Users/jspooner/.rvm/gems/ruby-2.2.0/gems/spring-1.4.0/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/jspooner/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/jspooner/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'2.2.0 :002 >
Hello,
As of the September 12th conference Apple has changed their pass signing to include the WWDR in the signing process. I have integrated your gem into my app and it works great (Thanks by the way ;) ) however I can not open them on a device because it is missing this part of the signature.
Hy,
I'm creating a rails app with passbook.
Now i have problems with sending pushes for notification.
How i can set the notification_cert.pem - password to the passbook.rb?
I downloaded the version 0.4.1 of the passbook gem and it seems the Key ":notification_passphrase" in the line of the "mattr_accessor" in the passbook module is missing.
Is there another way to set the password?
Thanks for your help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.