Class: InovaFCM::Service
- Inherits:
-
Object
- Object
- InovaFCM::Service
- Defined in:
- lib/inova_fcm/service.rb
Constant Summary collapse
- MAX_TOPIC_REGISTRATION_BATCH_SIZE =
1000
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#notification ⇒ Object
readonly
Returns the value of attribute notification.
-
#registration_ids ⇒ Object
readonly
Returns the value of attribute registration_ids.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Instance Method Summary collapse
-
#initialize(registration_ids: [], notification: {}, data: {}, topic: SecureRandom.uuid + Time.now.to_i.to_s) ⇒ Service
constructor
A new instance of Service.
- #send_notification ⇒ Object
Constructor Details
#initialize(registration_ids: [], notification: {}, data: {}, topic: SecureRandom.uuid + Time.now.to_i.to_s) ⇒ Service
Returns a new instance of Service.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/inova_fcm/service.rb', line 10 def initialize(registration_ids: [], notification: {}, data: {}, topic: SecureRandom.uuid + Time.now.to_i.to_s) @topic = topic @registration_ids = registration_ids.uniq @notification = notification @data = data InovaFCM.configuration.validate! @fcm = FCM.new(InovaFCM.configuration.fcm_key, InovaFCM.configuration.firebase_admin_sdk_path, InovaFCM.configuration.firebase_project_id) validate_attributes! end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/inova_fcm/service.rb', line 8 def data @data end |
#notification ⇒ Object (readonly)
Returns the value of attribute notification.
8 9 10 |
# File 'lib/inova_fcm/service.rb', line 8 def notification @notification end |
#registration_ids ⇒ Object (readonly)
Returns the value of attribute registration_ids.
8 9 10 |
# File 'lib/inova_fcm/service.rb', line 8 def registration_ids @registration_ids end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
8 9 10 |
# File 'lib/inova_fcm/service.rb', line 8 def topic @topic end |
Instance Method Details
#send_notification ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/inova_fcm/service.rb', line 25 def send_notification if @registration_ids.count > 1 bulk_send_notification else @fcm.send_v1() end end |