Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Firebase with a linux based client app for bidirectional messages communication with server

I've seen Google's documentation and a lot of examples over the internet about how to use Firebase within Android / iOS applications, but I want to develop a client Firebase application which runs on a linux machine.

My requirements are:

  • Client runs on linux environment (either writtern in C++ or python).
  • Server is written in Javascript (NodeJS).
  • Server and client should have bi-directional communication between them using firebase realtime database.

I've seen also the firebase REST api, but I assume that is not good enough for me since I haven't seen a client listener api that listens on a something like onValueChanged.

Question:

How can I implement a linux-based app in C++ or python that listens to messages from server (data changes) using a listener, without having to call some get function each and every few seconds (just like NodeJS have the ref.on("child_changed",...) or ref.on("value",...)?


Help is much appreciated!

like image 803
Mercury Avatar asked Oct 16 '18 19:10

Mercury


People also ask

Can you use Firebase for Linux?

Electron-Firebase provides a quickstart framework for building cloud-connected applications on Windows, macOS, and Linux.

How do we can send notifications to a specific device through Firebase Cloud Messaging service?

For sending FCM notification payload you can use Firebase Cloud Messaging Tool in firebase console. And click on Send your first message. Then enter the Title and body field. If you wish to send it to a particular device then click on Send test message and enter the FCM registration token.

Can we send SMS using Firebase?

You can send notification messages using the Notifications composer in the Firebase console. Though this does not provide the same flexibility or scalability as sending messages with the Admin SDK or the HTTP and XMPP protocols, it can be very useful for testing or for highly targeted marketing and user engagement.

How does Firebase in-app messaging work?

Firebase In-App Messaging helps you engage your app's active users by sending them targeted, contextual messages that encourage them to use key app features. For example, you could send an in-app message to get users to subscribe, watch a video, complete a level, or buy an item.


2 Answers

Unfortunately there is not official library for Realtime Database in Python but there are some third party wrappers around REST API.

Specifically I would look at Pyrebase library which also supports listening to live changes https://github.com/thisbejim/Pyrebase#streaming

For more information, libraries or other languages look at this page https://firebase.google.com/docs/database/rest/start

like image 92
Sgiath Avatar answered Sep 28 '22 04:09

Sgiath


Google offers a C++ SDK you can download it here.

There is also a tutorial on the bottom of the page, but if you really want to dig into some code, here is the quickstart code on github from google with examples for each category on Firebase.

Google has also implemented a Game for demonstration purposes in C++ for Desktop OSs. here There you can find more advanced features and code samples.

I have only tried it with an XCode project on Mac OS X, and it works fine. I have no code for real time database but you should find the sample project in the github repo. https://github.com/firebase/quickstart-cpp

I hope this helps!

Greetings.

like image 25
krjw Avatar answered Sep 28 '22 03:09

krjw