I am trying to do facebook authentication using firebase AngularFire2. I follow the same steps as this tutorial github.com/angular/angularfire2/blob/master/docs/Auth-with-Ionic2.md
But for some reason this does not work. This gives me a lot of errors from my provider page. Here is my code.
import { Injectable } from '@angular/core';
import { Component } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
@Injectable()
export class AuthService {
private authState: Observable<firebase.User>;
private currentUser: firebase.User;
constructor(public http: Http, public afAuth: AngularFireAuth) {
console.log('Hello AuthService Provider');
this.authState = afAuth.authState;
afAuth.subscribe((user: firebase.User) => {
this.currentUser = user;
});
}
get authenticated(): boolean {
return this.currentUser !== null;
}
signInWithFacebook(): firebase.Promise<any> {
return this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider());
}
signOut(): void {
this.afAuth.signOut();
}
displayName(): string {
if (this.currentUser !== null) {
return this.currentUser.facebook.displayName;
} else {
return '';
}
}
}
Mistakes
Property 'authState' does not exist on type 'AngularFireAuth'.
Argument of type '(user: User) => void' is not assignable to parameter of type '(value: FirebaseAuthState) => void'.
Types of parameters 'user' and 'value' are incompatible.
Type 'FirebaseAuthState' is not assignable to type 'User'.
Property 'delete' is missing in type 'FirebaseAuthState'.
Property 'auth' does not exist on type 'AngularFireAuth'.
I'm new to angular and ionic, please direct me here or go me a good tutorial
Mayur source
share