Class: Pushing::Adapters::HoustonAdapter
- Inherits:
-
Object
- Object
- Pushing::Adapters::HoustonAdapter
- Defined in:
- lib/pushing/adapters/apn/houston_adapter.rb
Instance Attribute Summary collapse
-
#certificate_path ⇒ Object
readonly
Returns the value of attribute certificate_path.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(apn_settings) ⇒ HoustonAdapter
constructor
A new instance of HoustonAdapter.
- #push!(notification) ⇒ Object
Constructor Details
#initialize(apn_settings) ⇒ HoustonAdapter
Returns a new instance of HoustonAdapter.
8 9 10 11 12 13 14 15 16 |
# File 'lib/pushing/adapters/apn/houston_adapter.rb', line 8 def initialize(apn_settings) @certificate_path = apn_settings.certificate_path @client = { production: Houston::Client.production, development: Houston::Client.development } @client[:production].certificate = @client[:development].certificate = File.read(certificate_path) end |
Instance Attribute Details
#certificate_path ⇒ Object (readonly)
Returns the value of attribute certificate_path.
6 7 8 |
# File 'lib/pushing/adapters/apn/houston_adapter.rb', line 6 def certificate_path @certificate_path end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/pushing/adapters/apn/houston_adapter.rb', line 6 def client @client end |
Instance Method Details
#push!(notification) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pushing/adapters/apn/houston_adapter.rb', line 18 def push!(notification) payload = notification.payload.dup aps = payload.delete(:aps) aps[:device] = notification.device_token houston_notification = Houston::Notification.new(payload.merge(aps)) client[notification.environment].push(houston_notification) rescue => cause error = Pushing::ApnDeliveryError.new("Error while trying to send push notification: #{cause.message}", nil, notification) raise error, error., cause.backtrace end |