Saturday, November 5, 2016

Firebase fever

Today I will share my experience and thoughts on Firebase.

Earlier this year someone approached me and asked that if costs (of a mobile app) could be decreased by using Parse.

I had no clue what Parse was, but my guess was that is a backend platform and didn't thought about it. All these years I have made my own Web APIs with PHP and MySQL and have been working great with Flash and Flex apps.

Fast forward in April I read that Parse was closing and everyone was starting looking for alternatives, that's when I investigated what Parse was.

Parse is a Backend as a Service provided by Facebook used my hundreds of thousands of developers. One day they suddenly decided to shut it down. No one knows why but one can speculate the obvious, it wasn't profitable enough.

At the same time I was investigating what was the fuzz about NoSQL and why it has been getting so popular. Basically it allows you save and retrieve simple datasets very fast.

I was starting to look around for a service that had a free tier that was good enough for learning, I found several services but all of them were pretty underwhelming until I found Firebase.

I liked that its free tier was fair and it had a well documented REST API. So I started using it and really liked how easy was to integrate it with ActionScript.

As you know you can't take things from granted, so I said that Firebase was good enough, but I still have my doubts to fully invest on it so I just kept toying around with their platform for the next weeks.

A month later Firebase switched from V2 to V3 and announced that they have been merged with some Google services. That's when I knew Firebase could be a good bet and started to get serious about it.

I developed some in-house projects to see how it compared with my previous stack (PHP + MySQL). And I was pleasantly surprised that the switch was smooth and almost painless.

Firebase offers several services for iOS, Android and Web, but only they have official documentation on Realtime Database using REST.

But that wasn't enough for me, I wanted to have Firebase Auth in my app so I couldn't have to do all the OAuth nonsense by myself (which I have also documented).

I began investigating if there was a method to login using only REST and yes there was a method. You needed to send some parameters to a special URL and listen for the responses.

To learn about this I created a simple app that stores To-Do lists that requires sign-up and sign-in to retrieve them.

Once I finished it I noticed that Firebase V2 was getting deprecated so I said to myself to not release it until I found out how to update it to V3.

Some weeks later someone found a way to do it in V3. When Firebase and Google merged they reused Google Identity Toolkit and named it Firebase Auth. The problem is that they left their documentation a bit incomplete so another round of trial and error was inbound.

This time I grabbed the JavaScript SDK and took a look. I found 4000 lines of minified JavaScript, thankfully string literals are not minified so I only had to search for certain keywords.

I figured out how the requests were made, how and what parameters needed to be sent and so on. I wish Firebase could document this but I now understand why they don't. It really was challenging understanding how their framework works at first, everything relies upon Access Tokens, Auth Tokens, id's, etc.

They made the choice to create very easy to use libraries so anyone could plug and play Firebase into their projects. That's fine and all but they are missing on people that don't use Java, Swift/Obj-C or JavaScript. You can easily use Firebase for a Windows/Mac/Linux game, console game or on a Internet of Things device.

Once I finished porting the ToDo app to Firebase V3, I thought to myself that it could be a waste to keep all this research for myself and that's when I wrote a comprehensive guide on how to use Firebase with only ActionScript and made several examples showcasing the most common uses.

Hopefully my efforts help a lot of people, I really was proud of what I made.

8 comments:

  1. Hello, thank you for sharing these examples!

    It's a pity that the Javascript SDK doesn't support the Notifications service, it would otherwise have been an extremely complete set for most programming needs, together with Authentication, Database and Storage.

    I just tried the Google Authentication tutorial, which worked very smoothly, but then I realised that I needed a way to log me out of the application, if not for anything else, in order to be able to see the login interface again!

    I have found that in JS one should call

    firebase.auth().signOut().then(function() {
    // Sign-out successful.
    }, function(error) {
    // An error happened.
    });

    but how can this be done with URLRequest? Or am I missing something obvious?


    Thanks,
    Kostas

    ReplyDelete
    Replies
    1. Hi,

      I believe the signOut method from Firebase only deletes the current user reference from memory because I haven't found anything on the Google Identity Toolkit to sign out.

      Please take a look at ToDo-App:

      https://github.com/PhantomAppDevelopment/todo-app

      In that app I created a helper class that allows you to signOut from your app with one line of code.

      Delete
  2. Thank you for your reply.

    I downloaded the project and read the source code. A lot of other things also were very helpful, like the custom skinning for Feathers.

    Once again, thank you for sharing.


    Kostas

    ReplyDelete
  3. You did an exceptional work on firebase.
    You're a star.
    Thank you.

    Icarus

    ReplyDelete
  4. Vint Ceramic Art | TITNIA & TECHNOLOGY
    Explore an titanium earrings all https://septcasino.com/review/merit-casino/ new “Vint worrione.com Ceramic Art” kadangpintar project https://jancasino.com/review/merit-casino/ on TITNIA & TECHNOLOGY. Our team of sculptors and artists have created new and

    ReplyDelete
  5. The motion by no means stops in our mobile Live Casino with video games obtainable to play 24/7 with a devoted helpline to give you complete support should you want it. Download the app 토토사이트 right now and you’ll ready to|be succesful of|have the power to} entry our full range of options and video games wherever you go. Browse our in depth casino video games record to find a game that’s simply right for you. Whether you’re a slot fanatic on the hunt for a mega jackpot, or an old-school gambler who loves taking on the house, there’s something for everyone at Wildz Casino.

    ReplyDelete
  6. When you engage in leisure playing, you’re not simply half in} in opposition to the percentages – you’re battling an enemy trained within the art of deceit and subterfuge who uses human nature in opposition to you. Accessing playing and pornography websites may well get more durable in Australia, if plans for obligatory age-verification go 1xbet ahead. But there are already technical workarounds for determined internet users. Characteristics and help-seeking behaviors of Internet gamblers primarily based on most problematic mode of playing. Isolating the influence of specific playing activities and modes on drawback playing and psychological misery in internet gamblers. We speak about California's playing initiatives, Twitch's new playing coverage, and method ahead for} betting on-line.

    ReplyDelete
  7. Whatever accountable playing support 솔 카지노 want to|you should|you have to} handle your play, OJO's here. There are many banking choices, with a minimal deposit starting from $5. The most impressive facet of Bit Starz is that bank transfers do not require any charges.

    ReplyDelete