markbates (owner)

Revisions

gist: 159858 Download_button fork
public
Public Clone URL: git://gist.github.com/159858.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
APN::Connection.open_for_delivery do |conn, sock|
  loop do
    notifications = APN::Notification.all(:conditions => {:sent_at => nil})
    unless notifications.nil? || notifications.empty?
      notifications.each do |noty|
        conn.write(noty.message_for_sending)
        noty.sent_at = Time.now
        noty.save
      end
    end
  end
end