What does it take to get started with Firebase?

I’m kinda new to Fuse and trying to implement Firebase in my Fuse app. I’ve done a search on the forum and came to find the following (interesting) resources:

  1. Fuse.Firebase - Fuse.Firebase
  2. fuse-firebase-js - fuse-firebase-js

The first one seems to have implemented the iOS and Android SDK. I didn’t try this one since it’s currently lacking documentation on realtime data-binding. The second one has implemented the Web SDK. I did try this one but I got stuck at errors where certain modules from the firebase node package cannot be found.

So here is where I’m in the dark: Is it potentially possible to ‘just’ load the firebase npm package and use the Web SDK inside the UX-files? Or will that never work and should I rely on the native SDK using something like Fuse.Firebase?

Fuse.Firebase is the way to go. If you have particular issues with it, please describe them as best you can and we’ll get you going. “lacking documentation on realtime data-binding” is not much to go on with, you’ll need to be more specific (have you read about Observables in Fuse?).

As for using npm modules in Fuse, the answer in most cases is it depends. If the module relies on being run either in a browser or in node environment, then it most likely won’t work with Fuse as-is.

Hi Uldis,

Yes I’ve read about Fuse Obervables. What I mean by lacking documentation is that I can’t find examples or docs on basic event bindings like the native equivalents of child_added, child_removed etc. with Fuse.Firebase. How does that work?

With JS I probably would have done something like this:

var Observable = require("FuseJS/Observable");
var data = Observable();
var items = []

firebase.database().ref('/users').on('child_added', snapshot => {
  items.push(snapshot.val())
  data.replaceAll(items)
})

But I have no clue on how to approach something similar with Fuse.Firebase.

Dear maartendings,

I would recommend you to see another example on [GitHub] (https://github.com/LuisRodriguezLD/Fuse-Tags-with-Firebase/blob/master/MainView.ux), it differs a bit (using REST principles) from the ones you posted earlier and may give a clue. It helped me.

Hi Leonids,

Thanks for the link. From what I can see in the code this works on timed intervals right? So you’re basically reaching out to the Firebase API every second to see if there are updates?

Although that’s a good idea it does unfortunately not make use of the powerful socket system behind Firebase. So I’m not sure if I want to go with that.

Hi maartendings,

You are right, it does sync once a defined time interval, 1 second in this case.
It worked for my project well, but indeed it is not close enough to socket functionality.
But for the time being I have no idea how to implement it using sockets is Fuse:(

I found some more info in this thread: https://github.com/fuse-compound/Fuse.Firebase/issues/31

So I cloned Fuse.Firebase in my own project. Then I updated my App.unoproj with the Projects attribute

"Projects": [
    "./Fuse.Firebase/src/Firebase/Firebase.unoproj",
    "./Fuse.Firebase/src/Firebase.Database/Firebase.Database.unoproj"
  ],

This returns an error which is probably coming from Firebase.Database.unoproj where Fuse.JSON/JSON.unoproj is referenced which doesn’t exist.

{
  "Projects": [
    "../Firebase/Firebase.unoproj",
    "../../Fuse.JSON/JSON.unoproj"
  ],
  "Packages": [
    "Fuse",
    "FuseJS"
  ],
  "Includes": [
    "*"
  ]
}

When I remove the reference I am actually able to build the project. However, when the app reloads on my iPhone I’m stuck with the error Firebase.Database.JS.DatabaseModule was not found.

Any pointers on where to go from here?

Following down the rabbit hole, I ended up on this commit in another fork.

I am trying the same thing without a luck.
However, here is the JSON GitHub.

The database binding working example still seems to be in the making. I’m hoping the author will provide it soon.

So with firebase realtime database/cloud firestore looking to be pretty far out on the horizon, I’m curious what are the popular DBs being used by the community with strong library support? I couldn’t find examples for direct use databases like this.

I’m looking into Firebase now too.
I think it should be possible to create NodeJS FireBase proxy, which can expose any API. And it can be consumed from FuseTools via socket.io. I’m already doing this with MS Bot Framework DirectLine API, which is not supported in FuseTools. And we already have Facebook Auth in our app done without FireBase package, so I’m going to try to make such proxy. Because I want to use FireBase for data storage and looks like there is no docs or HOWTOs on that.

So far, I’ve figured out that the following things are working:

var firebaseDb = require("Firebase/Database");
// how to listen
firebaseDb.listen('messages/user_id');
// how to get data
firebaseDb.on('data', function (path, msg) {
    if ('messages/user_id' === path) {
        console.log(msg); // JSON string
   }
});

But there are a lot of questions I have:

Docs: https://firebase.google.com/docs/database/web/read-and-write#detach_listeners

  • how to detach listener? (unsubscribe)

Docs: https://firebase.google.com/docs/database/web/lists-of-data#listen_for_child_events

  • how to receive update on child_added event?
  • how to receive update on child_removed event?
  • how to receive update on child_updated event?
  • how to receive update on child_moved event?

Wouldn’t it be better to try to run web version of FirebaseDatabase in FuseTools with some hacks?
Web version expects to see NodeJS or Browser environment, but if we can mock or fake those items, and give another analogs instead, wouldn’t it be much easier to work with firebase?

It’ very interesting to see that google’s flutter using very similar approach to what fuse is, but the underline language is dart, the composition of the UI use widget rather than XML , it would require deep learning curve. they mentioned there is a open source firebase wrapper for flutter, it would be great to come up with fuseJS for firebase based on flutter wrapper for firebase, from the developer’s prospective, picking up a new tool with a tightly integrated back-end DB would be a killer feature to fire the tool’s usage and come up with showcase app to promote the tool. I wish fuse team can hear this and discuss this seriously! again any app without back-end is almost useless.

I started a fuse project some time ago and the difficulty of backend integration as a firebase was a downside for me. Flutter already in the alpha version made available an implementation library for firebase and this attracted a lot of people to the tool. I particularly like the architecture and programming style of Fuse, but I particularly miss a scope for libraries that facilitate the backend with integrations of sdks.

When I remove the reference I am actually able to build the project. However, when the app reloads on my iPhone I’m stuck with the error Firebase.Database.JS.DatabaseModule was not found.

Any pointers on where to go from here?

Can you correct that? I have the same problem.

We’ve successfully integrated Firebase into our project, we have a fork where we extend original Fuse.Firebase repo from time to time: https://github.com/LIFEAI/Fuse.Firebase/tree/feature-database-lifeai

we also added some code examples in Readme.md file at the bottom.

Hi everyone! I was having a hard time choosing a good backend service for my apps, so just wanted to share my experience with you on that. Having some apps both at Google Play and Appstore, I used Parse until Facebook decided to shut it down. So, I was forced to search for alternatives and, to be honest, was not that happy as most of them didn’t fit my requirements as nicely.
Firstly, I checked Firebase, but it’s very limited in querying and indexing working on a nonSQL ecosystem with the database being a giant JSON doc. Then, it was AWS and Appery, both are not user-friendly and become rather expensive in no time. My next try was Kinvey, and it’s super expensive once you start doing something complex. I needed system to support social login, like Facebook, Twitter, Google, geolocation, and push notifications for both iOS and Android, so my final try was Backednless, I started for free and was able to figure out how to use it a lot faster than before, since support is pretty fast to answer. So far, it fits all of my needs and functionality is on point. Hope this helped.

I also use Backendless in my app on both IOS and Android. I simply use their Rest API without fault. RayJ have you integrated their SDK or are you using REST? Thanks. Steven.

Hello, have you ever encounter the error Firebase.Database.JS.DatabaseModule when using the Fuse Preview? if so, how did you fixed it? Thanks :slight_smile: