Permalink
Browse files

Merge pull request #7 from calonso/master

Fixed multiple app notifications bug
  • Loading branch information...
2 parents 46b53f1 + 6bbd74c commit eb0934a2f5d571d2998060d834a7e92fc9a426a5 @timsu committed Oct 4, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/apn_on_rails/app/models/apn/app.rb
@@ -40,7 +40,9 @@ def self.send_notifications
def self.send_notifications_for_cert(the_cert, app_id)
begin
APN::Connection.open_for_delivery({:cert => the_cert}) do |conn, sock|
- unset = APN::Notification.where(:sent_at => nil).order(:device_id, :created_at)
+ unset = APN::Notification.joins(:device).
+ where(:sent_at => nil, :apn_devices => { :app_id => app_id }).
+ order(:device_id, :created_at).readonly(false)
unset.each do |noty|
Rails.logger.debug "Sending notification ##{noty.id}"
begin

0 comments on commit eb0934a

Please sign in to comment.