Module: APNS
- Defined in:
- lib/pushmeup/apns/core.rb,
lib/pushmeup/apns/notification.rb
Defined Under Namespace
Classes: Notification
Class Attribute Summary collapse
-
.host ⇒ Object
Returns the value of attribute host.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.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(device_token, message) ⇒ Object
- .send_notifications(notifications) ⇒ Object
- .start_persistence ⇒ Object
- .stop_persistence ⇒ Object
Class Attribute Details
.host ⇒ Object
Returns the value of attribute host.
22 23 24 |
# File 'lib/pushmeup/apns/core.rb', line 22 def host @host end |
.logger ⇒ Object
Returns the value of attribute logger.
22 23 24 |
# File 'lib/pushmeup/apns/core.rb', line 22 def logger @logger end |
.pass ⇒ Object
Returns the value of attribute pass.
22 23 24 |
# File 'lib/pushmeup/apns/core.rb', line 22 def pass @pass end |
.pem ⇒ Object
Returns the value of attribute pem.
22 23 24 |
# File 'lib/pushmeup/apns/core.rb', line 22 def pem @pem end |
.port ⇒ Object
Returns the value of attribute port.
22 23 24 |
# File 'lib/pushmeup/apns/core.rb', line 22 def port @port end |
Class Method Details
.feedback ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pushmeup/apns/core.rb', line 53 def self.feedback sock, ssl = self.feedback_connection apns_feedback = [] while line = ssl.read(38) # Read lines from the socket line.strip! f = line.unpack('N1n1H140') apns_feedback << { :timestamp => Time.at(f[0]), :token => f[2] } end ssl.close sock.close return apns_feedback end |
.send_notification(device_token, message) ⇒ Object
36 37 38 39 |
# File 'lib/pushmeup/apns/core.rb', line 36 def self.send_notification(device_token, ) n = APNS::Notification.new(device_token, ) self.send_notifications([n]) end |
.send_notifications(notifications) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pushmeup/apns/core.rb', line 41 def self.send_notifications(notifications) @logger.info "Pushmeup: sending message(s): '#{notifications.map { |n| n.packaged_message}.join("|")}' to #{self.host}" @mutex.synchronize do self.with_connection do notifications.each do |n| @ssl.write(n.packaged_notification) end end end end |
.start_persistence ⇒ Object
25 26 27 |
# File 'lib/pushmeup/apns/core.rb', line 25 def self.start_persistence @persistent = true end |
.stop_persistence ⇒ Object
29 30 31 32 33 34 |
# File 'lib/pushmeup/apns/core.rb', line 29 def self.stop_persistence @persistent = false @ssl.close @sock.close end |