/fcm_client

The Ruby gem for the FCM REST API automatically generated by the OpenAPI Generator project.

Primary LanguageRuby

fcm_client

FcmClient - the Ruby gem for the Google Firebase Cloud Messaging REST API

Using the Firebase Admin SDK or FCM app server protocols, you can build message requests and send them to targets.

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: v1
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build fcm_client.gemspec

Then either install the gem locally:

gem install ./fcm_client-1.0.0.gem

(for development, run gem install --dev ./fcm_client-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'fcm_client', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'fcm_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'fcm_client'

# Setup authorization
FcmClient.configure do |config|
  # Configure API key authorization: Admin
  config.api_key['Authorization'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['Authorization'] = 'Bearer'
end

api_instance = FcmClient::MessagesApi.new
project_id = 'myproject-b5ae1' # String | A valid GCP project ID.
inline_object = FcmClient::InlineObject.new # InlineObject | 

begin
  #Send messages to topics
  result = api_instance.v1_projects_project_id_messagessend_post(project_id, inline_object)
  p result
rescue FcmClient::ApiError => e
  puts "Exception when calling MessagesApi->v1_projects_project_id_messagessend_post: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://fcm.googleapis.com

Class Method HTTP request Description
FcmClient::MessagesApi v1_projects_project_id_messagessend_post POST /v1/projects/{project_id}/messages:send Send messages to topics

Documentation for Models

Documentation for Authorization

Admin

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header