Class: Google::Apis::FcmV1::FirebaseCloudMessagingService

Inherits:
Core::BaseService show all
Defined in:
generated/google/apis/fcm_v1/service.rb

Overview

Firebase Cloud Messaging API

FCM send API that provides a cross-platform messaging solution to reliably deliver messages at no cost.

Examples:

require 'google/apis/fcm_v1'

Fcm = Google::Apis::FcmV1 # Alias the module
service = Fcm::FirebaseCloudMessagingService.new

See Also:

Instance Attribute Summary collapse

Attributes inherited from Core::BaseService

#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path

Instance Method Summary collapse

Methods inherited from Core::BaseService

#batch, #batch_upload, #fetch_all, #http

Methods included from Core::Logging

#logger

Constructor Details

#initializeFirebaseCloudMessagingService

Returns a new instance of FirebaseCloudMessagingService.


46
47
48
49
# File 'generated/google/apis/fcm_v1/service.rb', line 46

def initialize
  super('https://fcm.googleapis.com/', '')
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

Returns:

  • (String)

    API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.


39
40
41
# File 'generated/google/apis/fcm_v1/service.rb', line 39

def key
  @key
end

#quota_userString

Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

Returns:

  • (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.


44
45
46
# File 'generated/google/apis/fcm_v1/service.rb', line 44

def quota_user
  @quota_user
end

Instance Method Details

#send_message(parent, send_message_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::FcmV1::Message

Send a message to specified target (a registration token, topic or condition).

Parameters:

  • parent (String)

    Required. It contains the Firebase project id (i.e. the unique identifier for your Firebase project), in the format of projects/project_id. For legacy support, the numeric project number with no padding is also supported in the format of `projects/`project_number.

  • send_message_request_object (Google::Apis::FcmV1::SendMessageRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:


76
77
78
79
80
81
82
83
84
85
86
# File 'generated/google/apis/fcm_v1/service.rb', line 76

def send_message(parent, send_message_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1/{+parent}/messages:send', options)
  command.request_representation = Google::Apis::FcmV1::SendMessageRequest::Representation
  command.request_object = send_message_request_object
  command.response_representation = Google::Apis::FcmV1::Message::Representation
  command.response_class = Google::Apis::FcmV1::Message
  command.params['parent'] = parent unless parent.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end