Class: Maia::FCM::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/maia/fcm/service.rb

Instance Method Summary collapse

Constructor Details

#initializeService

Returns a new instance of Service.



4
5
6
# File 'lib/maia/fcm/service.rb', line 4

def initialize
  @connection ||= FCM::Connection.new key
end

Instance Method Details

#deliver(notification, *tokens, topic: nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/maia/fcm/service.rb', line 12

def deliver(notification, *tokens, topic: nil)
  responses = ResponseCollection.new notification
  responses << deliver_all(notification, tokens)
  responses << deliver_all(notification, "/topics/#{topic}") if topic
  responses
end

#keyObject



8
9
10
# File 'lib/maia/fcm/service.rb', line 8

def key
  ENV.fetch 'FCM_KEY', Maia::FCM.key
end