apn_sender 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -3
- data/VERSION +1 -1
- data/apn_sender.gemspec +1 -1
- data/lib/apn/connection/base.rb +12 -10
- data/lib/apn/sender_daemon.rb +3 -0
- data/lib/apn/tasks.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -49,9 +49,11 @@ For production, you're probably better off running a dedicated daemon and settin
|
|
49
49
|
# To run daemon. Pass --help to print all options
|
50
50
|
./script/apn_sender --environment=production --verbose start
|
51
51
|
|
52
|
-
Note the --environment must be explicitly set (separately from your <code>
|
52
|
+
Note the --environment must be explicitly set (separately from your <code>Rails.env</code>) to production in order to send messages via the production APN servers. Any other environment sends messages through Apple's sandbox servers at <code>gateway.sandbox.push.apple.com</code>.
|
53
53
|
|
54
|
-
|
54
|
+
Also, there are two similar options <code>:cert_path</code> and <code>:full_cert_path</code>. The former specifies the directory in which to file the .pem file (either apn_production.pem or apn_development.pem, depending on the environment). The latter specifies a .pem file explicitly, allowing customized certificate names for those that need them.
|
55
|
+
|
56
|
+
Check <code>logs/apn_sender.log</code> for debugging output. In addition to logging any major errors there, apn_sender hooks into the Resque::Worker logging to display any verbose or very_verbose worker output in apn_sender.log file as well.
|
55
57
|
|
56
58
|
|
57
59
|
=== 3. Checking Apple's Feedback Service
|
@@ -60,7 +62,7 @@ Since push notifications are a fire-and-forget sorta deal, where you get no indi
|
|
60
62
|
|
61
63
|
It's actually really simple - you connect to them periodically and they give you a big dump of tokens you shouldn't send to anymore. The gem wraps this up nicely -- just call:
|
62
64
|
|
63
|
-
# APN::Feedback accepts the same optional :environment and :cert_path options as APN::Sender
|
65
|
+
# APN::Feedback accepts the same optional :environment and :cert_path / :full_cert_path options as APN::Sender
|
64
66
|
feedback = APN::Feedback.new()
|
65
67
|
|
66
68
|
tokens = feedback.tokens # => Array of device tokens
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
data/apn_sender.gemspec
CHANGED
data/lib/apn/connection/base.rb
CHANGED
@@ -65,18 +65,20 @@ module APN
|
|
65
65
|
|
66
66
|
# Get a fix on the .pem certificate we'll be using for SSL
|
67
67
|
def setup_paths
|
68
|
-
# Set option defaults. RAILS_ROOT is still here not from Rails, but to handle passing in root from sender_daemon
|
69
|
-
@opts[:root_path] ||= defined?(::Rails.root) ? ::Rails.root.to_s : (defined?(RAILS_ROOT) ? RAILS_ROOT : '/')
|
70
|
-
@opts[:cert_path] ||= File.join(File.expand_path(@opts[:root_path]), "config", "certs")
|
71
68
|
@opts[:environment] ||= ::Rails.env if defined?(::Rails.env)
|
72
|
-
|
73
|
-
log_and_die("Missing certificate path. Please specify :cert_path when initializing class.") unless @opts[:cert_path]
|
74
|
-
|
75
|
-
cert_name = apn_production? ? "apn_production.pem" : "apn_development.pem"
|
76
|
-
cert_path = File.join(@opts[:cert_path], cert_name)
|
77
69
|
|
78
|
-
|
79
|
-
|
70
|
+
# Accept a complete :full_cert_path allowing arbitrary certificate names, or create a default from the Rails env
|
71
|
+
cert_path = @opts[:full_cert_path] || begin
|
72
|
+
# Note that RAILS_ROOT is still here not from Rails, but to handle passing in root from sender_daemon
|
73
|
+
@opts[:root_path] ||= defined?(::Rails.root) ? ::Rails.root.to_s : (defined?(RAILS_ROOT) ? RAILS_ROOT : '/')
|
74
|
+
@opts[:cert_path] ||= File.join(File.expand_path(@opts[:root_path]), "config", "certs")
|
75
|
+
@opts[:cert_name] ||= apn_production? ? "apn_production.pem" : "apn_development.pem"
|
76
|
+
|
77
|
+
File.join(@opts[:cert_path], @opts[:cert_name])
|
78
|
+
end
|
79
|
+
|
80
|
+
@apn_cert = File.read(cert_path) if File.exists?(cert_path)
|
81
|
+
log_and_die("Please specify correct :full_cert_path. No apple push notification certificate found in: #{cert_path}") unless @apn_cert
|
80
82
|
end
|
81
83
|
|
82
84
|
# Open socket to Apple's servers
|
data/lib/apn/sender_daemon.rb
CHANGED
@@ -29,6 +29,9 @@ module APN
|
|
29
29
|
opts.on('--cert-path=NAME', 'Path to directory containing apn .pem certificates.') do |path|
|
30
30
|
@options[:cert_path] = path
|
31
31
|
end
|
32
|
+
opts.on('c', '--full-cert-path=NAME', 'Full path to desired .pem certificate (overrides environment selector).') do |path|
|
33
|
+
@options[:full_cert_path] = path
|
34
|
+
end
|
32
35
|
opts.on('-n', '--number-of-workers=WORKERS', "Number of unique workers to spawn") do |worker_count|
|
33
36
|
@options[:worker_count] = worker_count.to_i rescue 1
|
34
37
|
end
|
data/lib/apn/tasks.rb
CHANGED
@@ -11,7 +11,7 @@ namespace :apn do
|
|
11
11
|
worker = nil
|
12
12
|
|
13
13
|
begin
|
14
|
-
worker = APN::Sender.new(:cert_path => ENV['CERT_PATH'], :environment => ENV['ENVIRONMENT'])
|
14
|
+
worker = APN::Sender.new(:full_cert_path => ENV['FULL_CERT_PATH'], :cert_path => ENV['CERT_PATH'], :environment => ENV['ENVIRONMENT'])
|
15
15
|
worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
|
16
16
|
worker.very_verbose = ENV['VVERBOSE']
|
17
17
|
rescue Exception => e
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apn_sender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kali Donovan
|