Class: APNS::Sender
- Inherits:
-
Object
- Object
- APNS::Sender
- Defined in:
- lib/apns/sender.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#pass ⇒ Object
readonly
Returns the value of attribute pass.
-
#pem ⇒ Object
readonly
Returns the value of attribute pem.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Sender
constructor
A new instance of Sender.
- #send_notifications(notifications) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Sender
Returns a new instance of Sender.
6 7 8 9 10 11 |
# File 'lib/apns/sender.rb', line 6 def initialize(params = {}) @host = params[:host] || 'gateway.sandbox.push.apple.com' @port = params[:port] || 2195 @pem = params[:pem] || raise("Path to your pem file required!") @pass = params[:pass] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/apns/sender.rb', line 4 def host @host end |
#pass ⇒ Object (readonly)
Returns the value of attribute pass.
4 5 6 |
# File 'lib/apns/sender.rb', line 4 def pass @pass end |
#pem ⇒ Object (readonly)
Returns the value of attribute pem.
4 5 6 |
# File 'lib/apns/sender.rb', line 4 def pem @pem end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/apns/sender.rb', line 4 def port @port end |
Instance Method Details
#send_notifications(notifications) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/apns/sender.rb', line 13 def send_notifications(notifications) packages = notifications.select(&:valid?).map { |n| Packager.new(n).package } return if packages.none? connection do |ssl| packages.each { |package| ssl.write(package) } end true end |