Module: APN::Connection

Defined in:
lib/apn_on_rails/libs/connection.rb

Class Method Summary collapse

Class Method Details

.open_for_delivery(options = {}, &block) ⇒ Object

Yields up an SSL socket to write notifications to. The connections are close automatically.

Example:
 APN::Configuration.open_for_delivery do |conn|
   conn.write('my cool notification')
 end

Configuration parameters are:

configatron.apn.passphrase = ''
configatron.apn.port = 2195
configatron.apn.host = 'gateway.sandbox.push.apple.com' # Development
configatron.apn.host = 'gateway.push.apple.com' # Production
configatron.apn.cert = File.join(rails_root, 'config', 'apple_push_notification_development.pem')) # Development
configatron.apn.cert = File.join(rails_root, 'config', 'apple_push_notification_production.pem')) # Production

22
23
24
# File 'lib/apn_on_rails/libs/connection.rb', line 22

def open_for_delivery(options = {}, &block)
  open(options, &block)
end

.open_for_feedback(options = {}, &block) ⇒ Object

Yields up an SSL socket to receive feedback from. The connections are close automatically. Configuration parameters are:

configatron.apn.feedback.passphrase = ''
configatron.apn.feedback.port = 2196
configatron.apn.feedback.host = 'feedback.sandbox.push.apple.com' # Development
configatron.apn.feedback.host = 'feedback.push.apple.com' # Production
configatron.apn.feedback.cert = File.join(rails_root, 'config', 'apple_push_notification_development.pem')) # Development
configatron.apn.feedback.cert = File.join(rails_root, 'config', 'apple_push_notification_production.pem')) # Production

36
37
38
39
40
41
42
# File 'lib/apn_on_rails/libs/connection.rb', line 36

def open_for_feedback(options = {}, &block)
  options = {:cert => configatron.apn.feedback.cert,
             :passphrase => configatron.apn.feedback.passphrase,
             :host => configatron.apn.feedback.host,
             :port => configatron.apn.feedback.port}.merge(options)
  open(options, &block)
end