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
22
23
# 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]

  @logger = APN::Log.new.write
end

Instance Method Details

#clientObject



42
43
44
# File 'lib/apn/feedback.rb', line 42

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

#dataObject



25
26
27
28
29
# File 'lib/apn/feedback.rb', line 25

def data
  @logger.info 'Trying to get feedback from Apple push notification server...'

  @feedback ||= receive
end

#receiveObject



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

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

  @logger.info 'Feedback received!'

  return feedbacks
end