Class: Rpush::Daemon::Fcm::Delivery
- Includes:
- MultiJsonHelper
- Defined in:
- lib/rpush/daemon/fcm/delivery.rb
Overview
Constant Summary collapse
- HOST =
'https://fcm.googleapis.com'.freeze
- SCOPE =
'https://www.googleapis.com/auth/firebase.messaging'.freeze
Instance Method Summary collapse
-
#initialize(app, http, notification, batch) ⇒ Delivery
constructor
A new instance of Delivery.
- #perform ⇒ Object
Methods included from MultiJsonHelper
#multi_json_dump, #multi_json_load
Methods inherited from Delivery
#mark_batch_delivered, #mark_batch_failed, #mark_batch_retryable, #mark_delivered, #mark_failed, #mark_retryable, #mark_retryable_exponential
Methods included from Loggable
#log_debug, #log_error, #log_info, #log_warn
Methods included from Reflectable
Constructor Details
#initialize(app, http, notification, batch) ⇒ Delivery
Returns a new instance of Delivery.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rpush/daemon/fcm/delivery.rb', line 11 def initialize(app, http, notification, batch) if necessary_data_exists?(app) @app = app @http = http @notification = notification @batch = batch @uri = URI.parse("#{HOST}/v1/projects/#{@app.firebase_project_id || ENV['FIREBASE_PROJECT_ID']}/messages:send") else Rpush.logger.error("Cannot find necessary configuration! Please make sure you have set all necessary ENV variables or firebase_project_id and json_key attributes.") end end |
Instance Method Details
#perform ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rpush/daemon/fcm/delivery.rb', line 24 def perform handle_response(do_post) rescue SocketError => error mark_retryable(@notification, Time.now + 10.seconds, error) raise rescue StandardError => error mark_failed(error) raise ensure @batch.notification_processed end |