Class: GCM::Service

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/mercurius/gcm/service.rb

Constant Summary collapse

BATCH_SIZE =
999

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeService

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

#attemptsObject (readonly)

Returns the value of attribute attempts.



10
11
12
# File 'lib/mercurius/gcm/service.rb', line 10

def attempts
  @attempts
end

#connectionObject

Returns the value of attribute connection.



9
10
11
# File 'lib/mercurius/gcm/service.rb', line 9

def connection
  @connection
end

#hostObject

Returns the value of attribute host.



9
10
11
# File 'lib/mercurius/gcm/service.rb', line 9

def host
  @host
end

#keyObject

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