Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Firebase with Ruby on Rails?

I've looked at different ruby gems like firebase-ruby and rest-firebase, but the gems don't integrate well with rails.

My question is, is there an easier way of using the ApplicationRecord design pattern with Firebase as my backend?

like image 618
ntholi Avatar asked Dec 13 '16 06:12

ntholi


People also ask

Does Firebase support Ruby?

The Google Cloud client libraries support Firebase access in Java, Python, Node. js, Go, PHP, C#, and Ruby. To get started with one of the Google Cloud client libraries, see the Quickstart using a Server Client Library.

Is Firebase frontend or backend?

Firebase is a Backend-as-a-Service (BaaS) app development platform that provides hosted backend services such as a realtime database, cloud storage, authentication, crash reporting, machine learning, remote configuration, and hosting for your static files.

Can I use Firebase for API?

API Usage. You can use any Firebase Realtime Database URL as a REST endpoint. All you need to do is append . json to the end of the URL and send a request from your favorite HTTPS client.

Can I use Firebase as a server?

Using the Firebase CLI, you deploy files from local directories on your computer to our Hosting servers. Beyond serving static content, you can use Cloud Functions for Firebase or Cloud Run to serve dynamic content and host microservices on your sites.


1 Answers

Firstly you need to get two things

  1. FIREBASE_SERVER_API_KEY
  2. FIREBASE_NOTIFICATION_URL.

After that just pass these in headers

{"Authorization" => "key=#{FIREBASE_SERVER_API_KEY}", "Content-Type" => "application/json"}

And in body pass these

{"registration_ids":
["pass-device-token"],
"priority":"high",
"data":{}}
like image 73
Aniket Tiwari Avatar answered Oct 13 '22 01:10

Aniket Tiwari