Class: Pushing::Adapters::AndpushAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/pushing/adapters/fcm/andpush_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fcm_settings) ⇒ AndpushAdapter

Returns a new instance of AndpushAdapter.



11
12
13
# File 'lib/pushing/adapters/fcm/andpush_adapter.rb', line 11

def initialize(fcm_settings)
  @server_key = fcm_settings.server_key
end

Instance Attribute Details

#server_keyObject (readonly)

Returns the value of attribute server_key.



9
10
11
# File 'lib/pushing/adapters/fcm/andpush_adapter.rb', line 9

def server_key
  @server_key
end

Instance Method Details

#push!(notification) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/pushing/adapters/fcm/andpush_adapter.rb', line 15

def push!(notification)
  FcmResponse.new(client.push(notification.payload))
rescue => e
  response = e.respond_to?(:response) ? FcmResponse.new(e.response) : nil
  error    = Pushing::FcmDeliveryError.new("Error while trying to send push notification: #{e.message}", response, notification)

  raise error, error.message, e.backtrace
end