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.
-
.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
Class Attribute Details
.host ⇒ Object
Returns the value of attribute host.
14 15 16 |
# File 'lib/pushmeup/apns/core.rb', line 14 def host @host end |
.pass ⇒ Object
Returns the value of attribute pass.
14 15 16 |
# File 'lib/pushmeup/apns/core.rb', line 14 def pass @pass end |
.pem ⇒ Object
Returns the value of attribute pem.
14 15 16 |
# File 'lib/pushmeup/apns/core.rb', line 14 def pem @pem end |
.port ⇒ Object
Returns the value of attribute port.
14 15 16 |
# File 'lib/pushmeup/apns/core.rb', line 14 def port @port end |
Class Method Details
.feedback ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pushmeup/apns/core.rb', line 38 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
17 18 19 20 |
# File 'lib/pushmeup/apns/core.rb', line 17 def self.send_notification(device_token, ) n = APNS::Notification.new(device_token, ) self.send_notifications([n]) end |
.send_notifications(notifications) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pushmeup/apns/core.rb', line 22 def self.send_notifications(notifications) sock, ssl = self.open_connection if(sock.nil? or ssl.nil?) puts "Failed to send notification as seems to be that the pem file doesn't exist" return 0 end notifications.each do |n| ssl.write(n.packaged_notification) end ssl.close sock.close end |