dr-apns 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +13 -6
- data/lib/apns/core.rb +16 -1
- metadata +2 -2
data/README.textile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
h1.
|
1
|
+
h1. dr-apns
|
2
2
|
|
3
|
-
|
3
|
+
dr-apns is a gem for accessing the Apple Push Notification Service that allows
|
4
4
|
both sending notifications and reading from apple's feedback service. This gem
|
5
|
-
is based
|
5
|
+
is based jtv-apns
|
6
6
|
|
7
7
|
h2. Install
|
8
8
|
|
9
9
|
<pre>
|
10
|
-
sudo gem install
|
10
|
+
sudo gem install dr-apns
|
11
11
|
</pre>
|
12
12
|
|
13
13
|
h2. Setup:
|
@@ -22,7 +22,7 @@ Next, run the following command to convert this .p12 file into a .pem file.
|
|
22
22
|
openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts
|
23
23
|
</pre>
|
24
24
|
|
25
|
-
This pem file should be stored somewhere secure that your application can access. Next, set the
|
25
|
+
This pem file should be stored somewhere secure that your application can access. Next, set the dr-apns configuration parameters:
|
26
26
|
|
27
27
|
<pre>
|
28
28
|
###################
|
@@ -77,6 +77,10 @@ device_token = '123abc456def'
|
|
77
77
|
|
78
78
|
APNS.send_notification(device_token, 'Hello iPhone!')
|
79
79
|
APNS.send_notification(device_token, :aps => {:alert => 'Hello iPhone!', :badge => 1, :sound => 'default'})
|
80
|
+
|
81
|
+
thread = APNS.send_notification_thread(device_token, 'Hello iPhone!')
|
82
|
+
thread = APNS.send_notification_thread(device_token, :aps => {:alert => 'Hello iPhone!', :badge => 1, :sound => 'default'})
|
83
|
+
thread.join
|
80
84
|
</pre>
|
81
85
|
|
82
86
|
h2. Example (Multiple notifications):
|
@@ -90,6 +94,9 @@ n1 = [device_token, :aps => { :alert => 'Hello...', :badge => 1, :sound => 'defa
|
|
90
94
|
n2 = [device_token, :aps => { :alert => '... iPhone!', :badge => 1, :sound => 'default' }]
|
91
95
|
|
92
96
|
APNS.send_notifications([n1, n2])
|
97
|
+
|
98
|
+
thread = APNS.send_notifications_thread([n1, n2])
|
99
|
+
thread.join
|
93
100
|
</pre>
|
94
101
|
|
95
102
|
|
@@ -117,7 +124,7 @@ end
|
|
117
124
|
|
118
125
|
h2. Accessing the feedback service
|
119
126
|
|
120
|
-
|
127
|
+
dr-apns provides a simple api to access Apple's feedback service. Below is an example for setting the feedback time on an ActiveRecord object corresponding to a device token.
|
121
128
|
|
122
129
|
<pre>
|
123
130
|
# APNS.feedback_each returns an array of Hash objects with the following keys
|
data/lib/apns/core.rb
CHANGED
@@ -29,7 +29,7 @@ module APNS
|
|
29
29
|
# Host for push notification service
|
30
30
|
# production: gateway.push.apple.com
|
31
31
|
# development: gateway.sandbox.apple.com
|
32
|
-
@host = 'gateway.sandbox.push.apple.com'
|
32
|
+
@host = nil #'gateway.sandbox.push.apple.com'
|
33
33
|
@port = 2195
|
34
34
|
|
35
35
|
# Host for feedback service
|
@@ -80,6 +80,20 @@ module APNS
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
def self.send_notification_thread(device_token, message)
|
84
|
+
thread = Thread.new do
|
85
|
+
self.send_notification(device_token, message)
|
86
|
+
end
|
87
|
+
return thread
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.send_notifications_thread(notifications)
|
91
|
+
thread = Thread.new do
|
92
|
+
self.send_notifications(notifications)
|
93
|
+
end
|
94
|
+
return thread
|
95
|
+
end
|
96
|
+
|
83
97
|
def self.feedback
|
84
98
|
apns_feedback = []
|
85
99
|
self.with_feedback_connection do |conn|
|
@@ -149,6 +163,7 @@ module APNS
|
|
149
163
|
def self.open_connection(host, port, pem)
|
150
164
|
raise "The path to your pem file is not set. (APNS.pem = /path/to/cert.pem)" unless self.pem
|
151
165
|
raise "The path to your pem file does not exist!" unless File.exist?(self.pem)
|
166
|
+
raise "APNs host is nil! (APNS.host='gateway.push.apple.com')" unless self.host
|
152
167
|
|
153
168
|
context = OpenSSL::SSL::SSLContext.new
|
154
169
|
context.cert = OpenSSL::X509::Certificate.new(File.read(self.pem))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dr-apns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -23,7 +23,7 @@ files:
|
|
23
23
|
- Rakefile
|
24
24
|
- lib/apns/core.rb
|
25
25
|
- lib/apns.rb
|
26
|
-
homepage: http://github.com/dongriab/
|
26
|
+
homepage: http://github.com/dongriab/dr-apns
|
27
27
|
licenses: []
|
28
28
|
post_install_message:
|
29
29
|
rdoc_options: []
|