Module: IOSPN

Included in:
Notification
Defined in:
lib/ios_push_notifications.rb,
lib/ios_push_notifications/device.rb,
lib/ios_push_notifications/notification.rb,
lib/ios_push_notifications/configuration.rb

Defined Under Namespace

Classes: Configuration, Device, Notification

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



25
26
27
# File 'lib/ios_push_notifications/configuration.rb', line 25

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



28
29
30
31
# File 'lib/ios_push_notifications/configuration.rb', line 28

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

Instance Method Details

#open(options = {}) {|ssl, sock| ... } ⇒ Object

Yields:

  • (ssl, sock)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ios_push_notifications.rb', line 16

def open(options = {}, &block)
  options = IOSPN.configuration.notification.merge(options)
  cert = File.read(options[:cert])
  ctx = OpenSSL::SSL::SSLContext.new
  ctx.key = OpenSSL::PKey::RSA.new(cert, options[:passphrase])
  ctx.cert = OpenSSL::X509::Certificate.new(cert)
  
  sock = TCPSocket.new(options[:host], options[:port])
  ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
  ssl.sync = true
  ssl.connect
  
  yield ssl, sock if block_given?
  ssl.close
  sock.close
end

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



13
14
15
# File 'lib/ios_push_notifications.rb', line 13

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:



37
38
39
40
# File 'lib/ios_push_notifications.rb', line 37

def open_for_feedback(options = {}, &block)
  options =  IOSPN.configuration.feedback.merge(options)
  Notification.open(options, &block)
end