Class: GCM::Service
- Inherits:
-
Object
- Object
- GCM::Service
- Includes:
- ActiveModel::Model
- Defined in:
- lib/mercurius/gcm/service.rb
Constant Summary collapse
- BATCH_SIZE =
999
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#host ⇒ Object
Returns the value of attribute host.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #deliver(notification, *tokens, topic: nil) ⇒ Object
-
#initialize ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize ⇒ Service
Returns a new instance of Service.
12 13 14 15 16 17 18 |
# File 'lib/mercurius/gcm/service.rb', line 12 def initialize(*) super @host ||= GCM.host @key ||= GCM.key @connection ||= GCM::Connection.new(@host, @key) @attempts = 0 end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
10 11 12 |
# File 'lib/mercurius/gcm/service.rb', line 10 def attempts @attempts end |
#connection ⇒ Object
Returns the value of attribute connection.
9 10 11 |
# File 'lib/mercurius/gcm/service.rb', line 9 def connection @connection end |
#host ⇒ Object
Returns the value of attribute host.
9 10 11 |
# File 'lib/mercurius/gcm/service.rb', line 9 def host @host end |
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/mercurius/gcm/service.rb', line 9 def key @key end |
Instance Method Details
#deliver(notification, *tokens, topic: nil) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/mercurius/gcm/service.rb', line 20 def deliver(notification, *tokens, topic: nil) responses = GCM::ResponseCollection.new notification responses << deliver_all(notification, tokens) responses << deliver_all(notification, topic) if topic responses end |