Class: Google::Apis::Messages::MessagesService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
lib/google/apis/messages/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_id:) ⇒ MessagesService

Returns a new instance of MessagesService.

Parameters:

  • project_id: (String)


16
17
18
19
20
# File 'lib/google/apis/messages/service.rb', line 16

def initialize(project_id:)
  @project_id = project_id

  super('https://fcm.googleapis.com/', 'v1/projects/{projectId}/')
end

Instance Attribute Details

#project_idString

Your project ID from Google Firebase Console console.firebase.google.com/

Returns:

  • (String)


13
14
15
# File 'lib/google/apis/messages/service.rb', line 13

def project_id
  @project_id
end

Instance Method Details

#notify_topic(message, options: nil, &block) ⇒ Object Also known as: notify

Notify topic subscribers with message



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/google/apis/messages/service.rb', line 26

def notify_topic(message, options: nil, &block)
  command = make_simple_command(:post, 'messages:send', options)
  command.request_representation = Google::Apis::Messages::Message::Representation
  command.request_object = message

  if !ENV['FIREBASE_DEBUG'].nil?
    log_json(command)
  end

  execute_or_queue_command(command, &block)
end