Module: ADCK

Defined in:
lib/adck.rb,
lib/adck/message.rb,
lib/adck/version.rb,
lib/adck/connection.rb,
lib/adck/notification.rb

Defined Under Namespace

Classes: Connection, Message, Notification

Constant Summary collapse

VERSION =
'0.2.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hostObject

Returns the value of attribute host.



17
18
19
# File 'lib/adck.rb', line 17

def host
  @host
end

.passObject

Returns the value of attribute pass.



17
18
19
# File 'lib/adck.rb', line 17

def pass
  @pass
end

.pemObject

Returns the value of attribute pem.



17
18
19
# File 'lib/adck.rb', line 17

def pem
  @pem
end

.portObject

Returns the value of attribute port.



17
18
19
# File 'lib/adck.rb', line 17

def port
  @port
end

Class Method Details

.feedbackObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/adck.rb', line 37

def feedback
  apns_feedback = []

  Connection.feedback.open do |sock, ssl|
    while line = sock.gets   # Read lines from the socket
      line.strip!
      f = line.unpack('N1n1H140')
      apns_feedback << [Time.at(f[0]), f[2]]
    end
  end

  apns_feedback
end

.send_notification(token, message = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/adck.rb', line 19

def send_notification token, message=nil
  if token.is_a?(Notification)
    n = token
  else
    n = Notification.new(token,message)
  end

  send_notifications([n])
end

.send_notifications(notifications) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/adck.rb', line 29

def send_notifications(notifications)
  Connection.new.open do |sock,ssl|
    notifications.each do |n|
      ssl.write(n.packaged_notification)
    end
  end
end