Class: Rpush::Daemon::Apns::Delivery
- Defined in:
- lib/rpush/daemon/apns/delivery.rb
Constant Summary collapse
- SELECT_TIMEOUT =
0.2
- ERROR_TUPLE_BYTES =
6
- APN_ERRORS =
{ 1 => "Processing error", 2 => "Missing device token", 3 => "Missing topic", 4 => "Missing payload", 5 => "Missing token size", 6 => "Missing topic size", 7 => "Missing payload size", 8 => "Invalid token", 255 => "None (unknown error)" }
Instance Method Summary collapse
-
#initialize(app, conneciton, notification, batch) ⇒ Delivery
constructor
A new instance of Delivery.
- #perform ⇒ Object
Methods inherited from Delivery
#mark_delivered, #mark_failed, #mark_retryable, #mark_retryable_exponential
Methods included from Loggable
#log_error, #log_info, #log_warn
Methods included from Reflectable
Constructor Details
#initialize(app, conneciton, notification, batch) ⇒ Delivery
Returns a new instance of Delivery.
19 20 21 22 23 24 |
# File 'lib/rpush/daemon/apns/delivery.rb', line 19 def initialize(app, conneciton, notification, batch) @app = app @connection = conneciton @notification = notification @batch = batch end |
Instance Method Details
#perform ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rpush/daemon/apns/delivery.rb', line 26 def perform begin @connection.write(@notification.to_binary) check_for_error if Rpush.config.check_for_errors mark_delivered log_info("#{@notification.id} sent to #{@notification.device_token}") rescue Rpush::DeliveryError, Rpush::Apns::DisconnectionError => error mark_failed(error.code, error.description) raise end end |