Closed kruzel closed 12 years ago
You can set up a cronjob with this rake command "rake gcm:notifications:deliver" and set the cronjob to run every 1min to check continuously
or if you want to deliver the notification from the code
What I used is, Instead of calling the rake task when ever your want to send notification I call this method in the controller
Gcm::Notification.send_notifications
Sample code
device_token = "12321321312"
device = Gcm::Device.find_or_create_by_registration_id(:registration_id => "#{device_token}")
notification = Gcm::Notification.new
notification.device = device
notification.collapse_key = "updates_available"
notification.delay_while_idle = false
notification.data = {:registration_ids => ["#{device_token}"], :data => {:message_text => "Message!!!!!"}}
notification.save!
Gcm::Notification.send_notifications
Kruzel, amal's method above is the way to go.
is there a way to continuously run gcm:notifications:deliver?