Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dmittal10 opened this issue Mar 17, 2011 · 1 comment
Open

Comments

@dmittal10
Copy link

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
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants