Skip to content

Instantly share code, notes, and snippets.

@jpoz
Created October 23, 2009 22:30
Show Gist options
  • Select an option

  • Save jpoz/217228 to your computer and use it in GitHub Desktop.

Select an option

Save jpoz/217228 to your computer and use it in GitHub Desktop.
module APNS
def self.send_notifications(notifications)
sock, ssl = self.open_connection
notifications.each do |n|
ssl.write(self.packaged_notification(n[0], n[1]))
end
ssl.close
sock.close
end
end
# usage
notification1 = ['1234-12314-123123-123123', 'Hello Hello']
notification2 = ['1234-12314-123123-123123', {:alert => 'Hello iPhone!', :badge => 1, :sound => 'default'}]
notifications = [notification1, notification2]
APNS.send_notifications(notifications)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment