Class: ActionNativePush::Service::Apns
- Inherits:
-
Object
- Object
- ActionNativePush::Service::Apns
- Defined in:
- lib/action_native_push/service/apns.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
30.seconds
- DEFAULT_POOL_SIZE =
5
Instance Method Summary collapse
-
#initialize(config) ⇒ Apns
constructor
A new instance of Apns.
- #push(notification) ⇒ Object
Constructor Details
#initialize(config) ⇒ Apns
Returns a new instance of Apns.
9 10 11 |
# File 'lib/action_native_push/service/apns.rb', line 9 def initialize(config) @config = config end |
Instance Method Details
#push(notification) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/action_native_push/service/apns.rb', line 16 def push(notification) reset_connection_error connection_pool.with do |connection| rescue_and_reraise_network_errors do apnotic_notification = apnotic_notification_from(notification) Rails.logger.info("Pushing APNs notification: #{apnotic_notification.apns_id}") response = connection.push \ apnotic_notification, timeout: config[:request_timeout] || DEFAULT_TIMEOUT raise connection_error if connection_error handle_response_error(response) unless response&.ok? end end end |