Skip to content

Instantly share code, notes, and snippets.

@AlexJWayne
Created December 20, 2009 06:42
Show Gist options
  • Select an option

  • Save AlexJWayne/260374 to your computer and use it in GitHub Desktop.

Select an option

Save AlexJWayne/260374 to your computer and use it in GitHub Desktop.
class Device < ActiveRecord::Base
has_many :reminders
acts_as_pushable :token
def self.send_reminders
last_push = Settings.last_push || Time.at(0)
Settings.last_push = Time.now
schedules = Schedule.all :conditions => ['schedules.time >= ?', last_push], :include => { :reminder => :device }
schedules.each do |schedule|
schedule.reminder.device.send_notification(
:alert => 'You have a new Reminder waiting to be viewed!',
:sound => true,
:custom => {
:reminder_id => schedule.reminder.id
}
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment