Firebase 3.0 Ionic & Facebook Login Clearly Innovative IncClearly Innovative | Web and Mobile Development

The Problem:

As we all have figured out since we updated to Firebase, we dont really have that nice integration with inAppBrowser like we did in the past. Since I did not want to give up on all of the goodness of the latest release of Firebase, I needed a solution.

I am using version 3.0.2 of Firebase and I have tested this on IOS, Android and in the web browser

I like plugins when I need to use them, but I prefer to utilize plugins as a last resort because I like to keep things simple.

Flashback to OpenFB

This is a pure javascript library for integrating facebook into your Ionic Application; with this and the existing Firebase APIs I am able to get Facebook Auth w/ Firebase working

https://github.com/ccoenraets/OpenFB

 

The code:

The code is pretty straightforward, you do all of the normal magic on the Facebook site to setup your application.

Follow the instructions on the OpenFB website for getting it integrated into your Ionic Application.

Add the Facebook Login to your code.

You can see that when the Facebook login is completed, I use the credentials/accessToken from the response to create the credentials for the FacebookAuthProvider

Then using that credential, I login to Firebase…

 Automatic Logging In:

The great thing is that once this is implemented, you get the session persisted automagically by Firebase and the user doesn’t need to login every time.

More Information: