Module: ADCK
- Defined in:
- lib/adck.rb,
lib/adck/message.rb,
lib/adck/version.rb,
lib/adck/connection.rb,
lib/adck/notification.rb
Defined Under Namespace
Classes: Connection, Message, Notification
Constant Summary collapse
- VERSION =
'0.2.0'
Class Attribute Summary collapse
-
.host ⇒ Object
Returns the value of attribute host.
-
.pass ⇒ Object
Returns the value of attribute pass.
-
.pem ⇒ Object
Returns the value of attribute pem.
-
.port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
- .feedback ⇒ Object
- .send_notification(token, message = nil) ⇒ Object
- .send_notifications(notifications) ⇒ Object
Class Attribute Details
.host ⇒ Object
Returns the value of attribute host.
17 18 19 |
# File 'lib/adck.rb', line 17 def host @host end |
.pass ⇒ Object
Returns the value of attribute pass.
17 18 19 |
# File 'lib/adck.rb', line 17 def pass @pass end |
.pem ⇒ Object
Returns the value of attribute pem.
17 18 19 |
# File 'lib/adck.rb', line 17 def pem @pem end |
.port ⇒ Object
Returns the value of attribute port.
17 18 19 |
# File 'lib/adck.rb', line 17 def port @port end |
Class Method Details
.feedback ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/adck.rb', line 37 def feedback apns_feedback = [] Connection.feedback.open do |sock, ssl| while line = sock.gets # Read lines from the socket line.strip! f = line.unpack('N1n1H140') apns_feedback << [Time.at(f[0]), f[2]] end end apns_feedback end |
.send_notification(token, message = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/adck.rb', line 19 def send_notification token, =nil if token.is_a?(Notification) n = token else n = Notification.new(token,) end send_notifications([n]) end |
.send_notifications(notifications) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/adck.rb', line 29 def send_notifications(notifications) Connection.new.open do |sock,ssl| notifications.each do |n| ssl.write(n.packaged_notification) end end end |