Skip to content

Angularfire2 Ionic2 facebook auth error #736

@theunreal

Description

@theunreal

Version info

Angular: 2.2.1

**Firebase:**3

**AngularFire:**beta 6

Other (e.g. Ionic/Cordova, Node, browser, operating system): Ionic 2 RC.4 - Cordova Android

Steps to set up and reproduce

signInWithFacebook(): firebase.Promise<FirebaseAuthState> {
    if (this.platform.is('cordova')) {
      console.log("trying to log in using cordova...");
      Facebook.login(['email', 'public_profile']).then(res => {
        console.log("Logged in. result here");
        const facebookCredential = firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken);
        console.log(firebase.auth().signInWithCredential(facebookCredential));
        return firebase.auth().signInWithCredential(facebookCredential);
      });
    } else {
      return this.auth$.login({
        provider: AuthProviders.Facebook,
        method: AuthMethods.Popup
      });
    }
  }

Debug output

** Errors in the JavaScript console **

The app works great in web browser. In Android, the login doese't work.
I debugged why the login button is not working and I found this errors:

EXCEPTION: Error in ./HomePage class HomePage - inline template:6:0 caused by: Cannot read property 'then' of undefined....

Logged in. result here

EXCEPTION: Uncaught (in promise): ReferenceError: firebase is not defined
ReferenceError: firebase is not defined
    at file:///android_asset/www/build/main.js:42039:42
    at t.invoke...

I tried to: console.log(this._auth.signInWithFacebook()); and it returned undefined.

Regards the second issue (firebase is not defined) I tried to
import firebase from 'firebase';
but Ionic 2 build returned error.

Expected behavior

Facebook login work on Android (Cordova)

Actual behavior

Login button return errors as described above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions