Sha256: b1773277fc7bd7919f3e6b4c70c0982be7615c80eb9ac9918255a68897465bbe
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module APN # This is the class that's actually enqueued via Resque when user calls +APN.notify+. # It gets added to the +apple_server_notifications+ Resque queue, which should only be operated on by # workers of the +APN::Sender+ class. class NotificationJob # Behind the scenes, this is the name of our Resque queue @queue = APN::QUEUE_NAME # Build a notification from arguments and send to Apple def self.perform(token, opts) msg = APN::Notification.new(token, opts) raise "Invalid notification options (did you provide :alert, :badge, or :sound?): #{opts.inspect}" unless msg.valid? raise "APN::NotificationJob was picked up by a non-APN:Sender resque worker. Aborting." unless worker worker.send_to_apple(msg) end # Only execute this job in specialized APN::Sender workers, since # standard Resque workers don't maintain the persistent TCP connection. extend Resque::Plugins::AccessWorkerFromJob self.required_worker_class = 'APN::Sender' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
apn_sender-1.0.6 | lib/apn/notification_job.rb |