apn_sender 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +8 -3
- data/VERSION +1 -1
- data/apn_sender.gemspec +1 -1
- data/lib/apn.rb +0 -3
- data/lib/apn/sender.rb +1 -1
- data/lib/apn/tasks.rb +4 -4
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= apn_sender
|
2
2
|
|
3
|
-
So you're building the server component of an iPhone application in Ruby. And you want to send background notifications through the Apple Push Notification servers, which doesn't seem too bad. But then you read in the {Apple Documentation}[https://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/WhatAreRemoteNotif/WhatAreRemoteNotif.html#//apple_ref/doc/uid/TP40008194-CH102-SW7] (<em>Apple Dev account required</em>) that
|
3
|
+
So you're building the server component of an iPhone application in Ruby. And you want to send background notifications through the Apple Push Notification servers, which doesn't seem too bad. But then you read in the {Apple Documentation}[https://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/WhatAreRemoteNotif/WhatAreRemoteNotif.html#//apple_ref/doc/uid/TP40008194-CH102-SW7] (<em>Apple Dev account required</em>) that Apple's servers may treat non-persistent connections as a Denial of Service attack, and things started looking more complicated.
|
4
4
|
|
5
5
|
If this doesn't sound familiar, this gem probably isn't anything you need. If it does, though...
|
6
6
|
|
@@ -49,11 +49,16 @@ There's also an included sample <code>apn_sender.monitrc</code> file in the <cod
|
|
49
49
|
|
50
50
|
APN is built on top of {Resque}[http://github.com/defunkt/resque] (an awesome {Redis}[http://code.google.com/p/redis/]-based background runner similar to {delayed_job}[http://github.com/collectiveidea/delayed_job]). Read through the {Resque README}[http://github.com/defunkt/resque#readme] to get a feel for what's going on, follow the installation instructions there, and then run:
|
51
51
|
|
52
|
-
$ sudo gem install
|
52
|
+
$ sudo gem install apn_sender
|
53
53
|
|
54
54
|
In your Rails app, add
|
55
55
|
|
56
|
-
config.gem '
|
56
|
+
config.gem 'apn_sender', :lib => 'apn'
|
57
|
+
|
58
|
+
To add a few useful rake tasks for running workers, add the following line to your Rakefile:
|
59
|
+
|
60
|
+
require 'apn/tasks'
|
61
|
+
|
57
62
|
|
58
63
|
== Copyright
|
59
64
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/apn_sender.gemspec
CHANGED
data/lib/apn.rb
CHANGED
data/lib/apn/sender.rb
CHANGED
@@ -113,7 +113,7 @@ __END__
|
|
113
113
|
|
114
114
|
## To enqueue test job
|
115
115
|
Resque.enqueue APN::NotificationJob, 'ceecdc18 ef17b2d0 745475e0 0a6cd5bf 54534184 ac2649eb 40873c81 ae76dbe8', {:alert => 'Resque Test'}
|
116
|
-
|
116
|
+
APN.notify 'ceecdc18 ef17b2d0 745475e0 0a6cd5bf 54534184 ac2649eb 40873c81 ae76dbe8', 'Resque Test'
|
117
117
|
|
118
118
|
## To run worker from rake task
|
119
119
|
CERT_PATH=/Users/kali/Code/insurrection/certs/ ENVIRONMENT=production rake apn:work
|
data/lib/apn/tasks.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Slight modifications from the default Resque tasks
|
2
2
|
namespace :apn do
|
3
3
|
task :setup
|
4
|
-
task :
|
5
|
-
task :
|
4
|
+
task :work => :sender
|
5
|
+
task :workers => :senders
|
6
6
|
|
7
7
|
desc "Start an APN worker"
|
8
|
-
task :
|
8
|
+
task :sender => :setup do
|
9
9
|
require 'lib/apple_push_notification'
|
10
10
|
|
11
11
|
worker = nil
|
@@ -25,7 +25,7 @@ namespace :apn do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
desc "Start multiple APN workers. Should only be used in dev mode."
|
28
|
-
task :
|
28
|
+
task :senders do
|
29
29
|
threads = []
|
30
30
|
|
31
31
|
ENV['COUNT'].to_i.times do
|