Ionic native Facebook with Firebase


#1

Hello!
I am trying to implement a Facebook Login within my Ionic 2 App.
I can successfully login with Facebook, but I am not able to generate the credentials, because I get this error:

ReferenceError: firebase is not defined
at main.js:37869
at t.invoke (polyfills.js:3)
at Object.onInvoke (main.js:35516)
at t.invoke (polyfills.js:3)
at e.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (main.js:35507)
at t.invokeTask (polyfills.js:3)
at e.runTask (polyfills.js:3)

I tried implementing Firebase on top of my file with these comands:
import firebase from “firebase”;
or
import * as firebase from “firebase”;

But with this commands I cannot even compile my application.

This is my code:

Facebook.login(['email']).then((response)=>{
  const firebaseCredential = firebase.auth.FacebookAuthProvider.credential(response.authResponse.accessToken);
  
  let providerConfig = {
    provider:AuthProviders.Facebook,
    method:AuthMethods.OAuthToken,
    remember:"default",
    scope:["email"]
  };  
  
  this.af.auth.login(firebaseCredential,providerConfig).then(suc=>{
    console.log("successful2");
    console.log(suc);
  });
}).catch((error)=>{console.log(error);});

Thank you for your help!


#2

full example in the doc… https://github.com/angular/angularfire2/blob/master/docs/Auth-with-Ionic2.md

here is a project - https://github.com/aaronksaunders/AngularFire2-Ionic2-Facebook


#3

Unfortunately this didn’t solve the problem.
I followed the instructions, but it keeps telling me that firebase is not defined.
Do you know how I can fix this issue?


#4

I posted the link to my project that works. Without seeing more of your source code, it is difficult to do anything else


#5

Are this all the necessary files?
https://mega.nz/#F!aIEXya7C!b5fxfSIIhdP0H06etaeRKA
Thank you for your help!