Created
December 20, 2009 06:42
-
-
Save AlexJWayne/260374 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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