Class: APN::Feedback

Inherits:
Object
  • Object
show all
Defined in:
lib/apn/feedback.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Feedback

Returns a new instance of Feedback.



12
13
14
15
16
17
18
19
20
21
# File 'lib/apn/feedback.rb', line 12

def initialize(options = {})
  options[:host]        ||= 'feedback.push.apple.com'
  options[:port]        ||= 2196
  options[:password]    ||= ''

  @cert = options[:cert]
  @password = options[:password]
  @host = options[:host]
  @port = options[:port]
end

Instance Method Details

#clientObject



40
41
42
# File 'lib/apn/feedback.rb', line 40

def client
  @client ||= APN::Client.new(host: @host, port: @port, cert: APN.config.cert_file, password: APN.config.cert_password)
end

#dataObject



23
24
25
26
27
# File 'lib/apn/feedback.rb', line 23

def data
  APN.log(:info, 'Trying to get feedback from Apple push notification server...')

  @feedback ||= receive
end

#receiveObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/apn/feedback.rb', line 29

def receive
  feedbacks = []
  while f = client.feedback
    feedbacks << f
  end

  APN.log(:info, 'Feedback received!')

  return feedbacks
end