Class: ActionPushNative::Service::Fcm
- Inherits:
-
Object
- Object
- ActionPushNative::Service::Fcm
- Includes:
- NetworkErrorHandling
- Defined in:
- lib/action_push_native/service/fcm.rb
Defined Under Namespace
Classes: HttpxSession, TokenProvider
Instance Method Summary collapse
-
#initialize(config) ⇒ Fcm
constructor
A new instance of Fcm.
- #push(notification) ⇒ Object
Constructor Details
#initialize(config) ⇒ Fcm
Returns a new instance of Fcm.
8 9 10 |
# File 'lib/action_push_native/service/fcm.rb', line 8 def initialize(config) @config = config end |
Instance Method Details
#push(notification) ⇒ Object
12 13 14 15 |
# File 'lib/action_push_native/service/fcm.rb', line 12 def push(notification) response = httpx_session.post("v1/projects/#{config.fetch(:project_id)}/messages:send", json: payload_from(notification)) handle_error(response) if response.error end |