Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

rake apn:notifications:deliver not able to send all notifications #31

Open
dmittal10 opened this Issue · 1 comment

2 participants

@dmittal10

I have records in apn_notifications table with NIL 'sent_at'.
But after running command
rake apn:notifications:deliver

Some still remains with sent_at as NIL.

Is there any issue with gem or my following code.

def perform
tracker = PushTracker.find(@tracker_id)
begin
notifications = APN::Notification.all(:conditions => 'sent_at IS NULL')
if(!notifications.empty?)
tracker.start_sending = Time.now if tracker.start_sending.nil?
tracker.end_sending = Time.now
tracker.sending = true
tracker.save!
#send the notifications
system "rake apn:notifications:deliver"
#set up another delayed job in the future in case they all didn't go through
Delayed::Job.enqueue(PushSender.new(@tracker_id),0, 5.minutes.from_now)
else
tracker.clean! if defined?(tracker) && !tracker.nil?
end
rescue => e
HoptoadNotifier.notify(
:error_class => "Push Sender",
:error_message => "Push Sender Error: #{e.message}",
:request => {:tracker => tracker, :exception => e}
)
tracker.clean! if defined?(tracker) && !tracker.nil?
end

end

Note: I am running above piece of code as heroku delayed job.

Any help would be appreciated.

Thnaks.

@bmorrall

I had a few problems with the line system "rake apn:notifications:deliver" on Heroku.

In my own project, I changed that line to APN::App.send_notifications, based on the task declaration found in lib/apn_on_rails/tasks/apn.rake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.