Module: APNS
- Defined in:
- lib/apns/core.rb
Overview
Copyright © 2009 James Pozdena, 2010 Justin.tv
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Class Attribute Summary collapse
-
.cache_connections ⇒ Object
Returns the value of attribute cache_connections.
-
.feedback_host ⇒ Object
Returns the value of attribute feedback_host.
-
.feedback_port ⇒ Object
Returns the value of attribute feedback_port.
-
.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
- .establish_notification_connection ⇒ Object
- .feedback ⇒ Object
- .has_notification_connection? ⇒ Boolean
- .send_notification(device_token, message) ⇒ Object
- .send_notifications(notifications) ⇒ Object
Class Attribute Details
.cache_connections ⇒ Object
Returns the value of attribute cache_connections.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def cache_connections @cache_connections end |
.feedback_host ⇒ Object
Returns the value of attribute feedback_host.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def feedback_host @feedback_host end |
.feedback_port ⇒ Object
Returns the value of attribute feedback_port.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def feedback_port @feedback_port end |
.host ⇒ Object
Returns the value of attribute host.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def host @host end |
.pass ⇒ Object
Returns the value of attribute pass.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def pass @pass end |
.pem ⇒ Object
Returns the value of attribute pem.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def pem @pem end |
.port ⇒ Object
Returns the value of attribute port.
49 50 51 |
# File 'lib/apns/core.rb', line 49 def port @port end |
Class Method Details
.establish_notification_connection ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/apns/core.rb', line 52 def self.establish_notification_connection if @cache_connections begin self.get_connection(self.host, self.port) return true rescue end end return false end |
.feedback ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/apns/core.rb', line 83 def self.feedback apns_feedback = [] self.with_feedback_connection do |conn| # Read buffers data from the OS, so it's probably not # too inefficient to do the small reads while data = conn.read(38) apns_feedback << self.parse_feedback_tuple(data) end end return apns_feedback end |
.has_notification_connection? ⇒ Boolean
63 64 65 |
# File 'lib/apns/core.rb', line 63 def self.has_notification_connection? return self.has_connection?(self.host, self.port) end |
.send_notification(device_token, message) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/apns/core.rb', line 67 def self.send_notification(device_token, ) self.with_notification_connection do |conn| conn.write(self.packaged_notification(device_token, )) conn.flush end end |
.send_notifications(notifications) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/apns/core.rb', line 74 def self.send_notifications(notifications) self.with_notification_connection do |conn| notifications.each do |n| conn.write(self.packaged_notification(n[0], n[1])) end conn.flush end end |