apn_sender 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +15 -0
- data/VERSION +1 -1
- data/apn_sender.gemspec +30 -33
- data/contrib/apn_sender.monitrc +1 -0
- data/lib/apn.rb +1 -0
- data/lib/apn/notification.rb +1 -1
- data/lib/apn/queue_manager.rb +1 -0
- data/lib/apn/sender.rb +0 -30
- metadata +16 -8
- data/.gitignore +0 -21
data/README.rdoc
CHANGED
@@ -87,6 +87,21 @@ Forcing a reconnect is as easy as calling either method with the single paramete
|
|
87
87
|
|
88
88
|
If you're sending notifications, you should definitely call one of the <code>receive</code> methods periodically, as Apple's policies require it and they apparently monitors providers for compliance. I'd definitely recommend throwing together a quick rake task to take care of this for you (the {whenever library}[http://github.com/javan/whenever] provides a nice wrapper around scheduling tasks to run at certain times (for systems with cron enabled)).
|
89
89
|
|
90
|
+
Just for the record, this is essentially what you want to have whenever run periodically for you:
|
91
|
+
|
92
|
+
def self.clear_uninstalled_applications
|
93
|
+
feedback_data = APN::Feedback.new(:environment => :production).data
|
94
|
+
|
95
|
+
feedback_data.each do |item|
|
96
|
+
user = User.find_by_iphone_token( item.token )
|
97
|
+
|
98
|
+
if user.iphone_token_updated_at && user.iphone_token_updated_at > item.timestamp
|
99
|
+
return true # App has been reregistered since Apple determined it'd been uninstalled
|
100
|
+
else
|
101
|
+
user.update_attributes(:iphone_token => nil, :iphone_token_updated_at => Time.now)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
90
105
|
|
91
106
|
|
92
107
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/apn_sender.gemspec
CHANGED
@@ -1,63 +1,60 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{apn_sender}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kali Donovan"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-04-22}
|
13
13
|
s.description = %q{Resque-based background worker to send Apple Push Notifications over a persistent TCP socket. Includes Resque tweaks to allow persistent sockets between jobs, helper methods for enqueueing APN notifications, and a background daemon to send them.}
|
14
14
|
s.email = %q{kali.donovan@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
"test/test_apple_push_notification.rb"
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"apn_sender.gemspec",
|
26
|
+
"contrib/apn_sender.monitrc",
|
27
|
+
"generators/apn_sender_generator.rb",
|
28
|
+
"generators/templates/script",
|
29
|
+
"init.rb",
|
30
|
+
"lib/apn.rb",
|
31
|
+
"lib/apn/connection/base.rb",
|
32
|
+
"lib/apn/feedback.rb",
|
33
|
+
"lib/apn/notification.rb",
|
34
|
+
"lib/apn/notification_job.rb",
|
35
|
+
"lib/apn/queue_manager.rb",
|
36
|
+
"lib/apn/queue_name.rb",
|
37
|
+
"lib/apn/sender.rb",
|
38
|
+
"lib/apn/sender_daemon.rb",
|
39
|
+
"lib/apn/tasks.rb",
|
40
|
+
"lib/resque/hooks/before_unregister_worker.rb",
|
41
|
+
"rails/init.rb",
|
42
|
+
"test/helper.rb",
|
43
|
+
"test/test_apple_push_notification.rb"
|
45
44
|
]
|
46
45
|
s.homepage = %q{http://github.com/kdonovan/apple_push_notification}
|
47
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
48
46
|
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = %q{1.
|
47
|
+
s.rubygems_version = %q{1.6.2}
|
50
48
|
s.summary = %q{Resque-based background worker to send Apple Push Notifications over a persistent TCP socket.}
|
51
49
|
s.test_files = [
|
52
50
|
"test/helper.rb",
|
53
|
-
|
51
|
+
"test/test_apple_push_notification.rb"
|
54
52
|
]
|
55
53
|
|
56
54
|
if s.respond_to? :specification_version then
|
57
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
58
55
|
s.specification_version = 3
|
59
56
|
|
60
|
-
if Gem::Version.new(Gem::
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
61
58
|
s.add_runtime_dependency(%q<resque>, [">= 0"])
|
62
59
|
s.add_runtime_dependency(%q<resque-access_worker_from_job>, [">= 0"])
|
63
60
|
else
|
data/contrib/apn_sender.monitrc
CHANGED
@@ -18,4 +18,5 @@ check process apn_sender
|
|
18
18
|
group apn_sender
|
19
19
|
start program = "/var/www/#{app_name}/current/script/apn_sender --environment=production --verbose start"
|
20
20
|
stop program = "/var/www/{#app_name}/current/script/apn_sender --environment=production --verbose stop"
|
21
|
+
if 2 restarts within 3 cycles then timeout
|
21
22
|
depends_on redis
|
data/lib/apn.rb
CHANGED
data/lib/apn/notification.rb
CHANGED
data/lib/apn/queue_manager.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
module APN
|
6
6
|
# Enqueues a notification to be sent in the background via the persistent TCP socket, assuming apn_sender is running (or will be soon)
|
7
7
|
def self.notify(token, opts = {})
|
8
|
+
token = token.to_s.gsub(/\W/, '')
|
8
9
|
APN::QueueManager.enqueue(APN::NotificationJob, token, opts)
|
9
10
|
end
|
10
11
|
|
data/lib/apn/sender.rb
CHANGED
@@ -45,33 +45,3 @@ module APN
|
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
48
|
-
|
49
|
-
|
50
|
-
__END__
|
51
|
-
|
52
|
-
# irb -r 'lib/apple_push_notification'
|
53
|
-
|
54
|
-
## To enqueue test job
|
55
|
-
k = 'ceecdc18 ef17b2d0 745475e0 0a6cd5bf 54534184 ac2649eb 40873c81 ae76dbe8'
|
56
|
-
c = '0f58e3e2 77237b8f f8213851 c835dee0 376b7a31 9e0484f7 06fe3035 7c5dda2f'
|
57
|
-
APN.notify k, 'Resque Test'
|
58
|
-
|
59
|
-
# If you need to really force quit some screwed up workers
|
60
|
-
Resque.workers.map{|w| Resque.redis.srem(:workers, w)}
|
61
|
-
|
62
|
-
# To run worker from rake task
|
63
|
-
CERT_PATH=/Users/kali/Code/insurrection/certs/ ENVIRONMENT=production rake apn:work
|
64
|
-
|
65
|
-
# To run worker from IRB
|
66
|
-
Resque.workers.map(&:unregister_worker)
|
67
|
-
require 'ruby-debug'
|
68
|
-
worker = APN::Sender.new(:cert_path => '/Users/kali/Code/insurrection/certs/', :environment => :production)
|
69
|
-
worker.very_verbose = true
|
70
|
-
worker.work(5)
|
71
|
-
|
72
|
-
# To run worker as daemon
|
73
|
-
args = ['--environment=production', '--cert-path=/Users/kali/Code/insurrection/certs/']
|
74
|
-
APN::SenderDaemon.new(args).daemonize
|
75
|
-
|
76
|
-
# To run daemonized version in Rails app
|
77
|
-
./script/apn_sender --environment=production start
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apn_sender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Kali Donovan
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-04-22 00:00:00 -06:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: resque
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: resque-access_worker_from_job
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -52,7 +57,6 @@ extra_rdoc_files:
|
|
52
57
|
- README.rdoc
|
53
58
|
files:
|
54
59
|
- .document
|
55
|
-
- .gitignore
|
56
60
|
- LICENSE
|
57
61
|
- README.rdoc
|
58
62
|
- Rakefile
|
@@ -81,28 +85,32 @@ homepage: http://github.com/kdonovan/apple_push_notification
|
|
81
85
|
licenses: []
|
82
86
|
|
83
87
|
post_install_message:
|
84
|
-
rdoc_options:
|
85
|
-
|
88
|
+
rdoc_options: []
|
89
|
+
|
86
90
|
require_paths:
|
87
91
|
- lib
|
88
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
89
94
|
requirements:
|
90
95
|
- - ">="
|
91
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
92
98
|
segments:
|
93
99
|
- 0
|
94
100
|
version: "0"
|
95
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
96
103
|
requirements:
|
97
104
|
- - ">="
|
98
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
99
107
|
segments:
|
100
108
|
- 0
|
101
109
|
version: "0"
|
102
110
|
requirements: []
|
103
111
|
|
104
112
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.6.2
|
106
114
|
signing_key:
|
107
115
|
specification_version: 3
|
108
116
|
summary: Resque-based background worker to send Apple Push Notifications over a persistent TCP socket.
|