lib/apn_on_rails/libs/feedback.rb
# Returns an Array of APN::Device objects that
# has received feedback from Apple. Each APN::Device will
# have it's <tt>feedback_at</tt> accessor marked with the time
# that Apple believes the device de-registered itself.
Returns an Array of APN::Device objects that
has received feedback from Apple. Each APN::Device will
have it's feedback_at accessor marked with the time
that Apple believes the device de-registered itself.
Returns an Array of APN :: Device objects that has received feedback from Apple . Each APN :: Device will have it ' s feedback_at accessor marked with the time that Apple believes the device de - registered itself .
def devices(&block)
        devices = []
        APN::Connection.open_for_feedback do |conn, sock|
          while line = sock.gets   
            line.strip!
            feedback = line.unpack('N1n1H140')
            token = feedback[2].scan(/.{0,8}/).join(' ').strip
            device = APN::Device.find(:first, :conditions => {:token => token})
            if device
              device.feedback_at = Time.at(feedback[0])
              devices << device
            end
          end
        end
        devices.each(&block) if block_given?
        return devices
      end
def devices ( & block ) devices = [ ] APN :: Connection . open_for_feedback do | conn , sock | while line = sock . gets line . strip! feedback = line . unpack ( 'N1n1H140' ) token = feedback [ 2 ] . scan ( / .{0,8} / ) . join ( ' ' ) . strip device = APN :: Device . find ( :first , :conditions => { :token => token } ) if device device . feedback_at = Time . at ( feedback [ 0 ] ) devices << device end end end devices . each ( & block ) if block_given? return devices end
Returns an Array of APN::Device objects that
has received feedback from Apple.
Returns an Array of APN :: Device objects that has received feedback from Apple .
# Read lines from the socket
block
<not_specific>