Sha256: e6baa43e20a720c4a477bc19dd5faa17626aa49f4aaeeed015e46faa213ff12d

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

module APN
  class FeedbackItem
    attr_accessor :timestamp, :token

    def initialize(time, token)
      @timestamp = time
      @token = token
    end
  end

  class Feedback
    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

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

      @feedback ||= receive
    end

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

      @logger.info 'Feedback received!'

      return feedbacks
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apn-1.0.2 lib/apn/feedback.rb
apn-1.0.1 lib/apn/feedback.rb
apn-1.0.0 lib/apn/feedback.rb