[](https://travis-ci.org/RaphaelJenni/FirebaseUI-Angular) [](https://badge.fury.io/js/firebaseui-angular
npm install @speakylink/firebaseui-angular

Only things done on this fork :
- update both package.json dependencies/peerDependencies to refer to @speakylink/firebaseui + npm install
- replace 3 occurences of 'firebaseui' by '@speakylink/firebaseui'
- replace 4 occurences of node_modules/firebaseui by node_modules/@speakylink/firebaseui
- replace 7 occurences of 'firebaseui-angular' by '@speakylink/firebaseui-angular'
- update the projects/firebaseui-angular-library/package.json name to @speakylink/firebaseui-angular, and suffix the version with -fr
- build the lib :
``sh`
npm run build-lib
`
- publish on npm :
sh`
cd dist/firebaseui-angular-library/
npm login
npm publish --access public
To install this library, run:
`bash`
$ npm install firebaseui-angular --save
To run this library you need to have AngularFire2, Firebase,
FirebaseUI-Web installed.
Fast install:
`bash`
$ npm install firebase firebaseui @angular/fire firebaseui-angular --save
Add the FirebaseUIModule with the config to your imports. Make sure you have initialized AngularFire correctly.
`typescript
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {AppComponent} from './app.component';
import {firebase, firebaseui, FirebaseUIModule} from '@speakylink/firebaseui-angular';
import {environment} from '../environments/environment';
import {AppRoutingModule} from './app-routing.module';
import {AngularFireModule} from '@angular/fire';
import {AngularFireAuthModule} from '@angular/fire/auth';
const firebaseUiAuthConfig: firebaseui.auth.Config = {
signInFlow: 'popup',
signInOptions: [
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
{
scopes: [
'public_profile',
'email',
'user_likes',
'user_friends'
],
customParameters: {
'auth_type': 'reauthenticate'
},
provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID
},
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
firebase.auth.GithubAuthProvider.PROVIDER_ID,
{
requireDisplayName: false,
provider: firebase.auth.EmailAuthProvider.PROVIDER_ID
},
firebase.auth.PhoneAuthProvider.PROVIDER_ID,
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
],
tosUrl: '
privacyPolicyUrl: '
credentialHelper: firebaseui.auth.CredentialHelper.ACCOUNT_CHOOSER_COM
};
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
AppRoutingModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireAuthModule,
FirebaseUIModule.forRoot(firebaseUiAuthConfig)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
`
Option 1: CSS Import
May be incompatible with older browsers.
Import the firebaseui css to your src/styles.css file:`css`
@import '~firebaseui/dist/firebaseui.css';
Option 2: Angular-CLI
File: angular.json
Path: "node_modules/@speakylink/firebaseui/dist/firebaseui.css"`json`
{
"projects": {
[your-project-name]: {
...
"architect": {
"build": {
"options": {
...
"styles": [
"src/styles.css",
"node_modules/@speakylink/firebaseui/dist/firebaseui.css"
]
}
},
...
"test": {
"options": {
...
"styles": [
"src/styles.css",
"node_modules/@speakylink/firebaseui/dist/firebaseui.css"
]
}
}
}
}
}
}
Option 3: HTML Link
Put this in the
tag of your index.html file:
`html
`
Make sure the version number matches the version of firebaseui you have installed with npm.
Once everything is set up, you can use the component in your Angular application:
`angular2html
`$3
For the configuration of the module see the official firebaseui documentation: Config_If you use a version prior to 3.3.0 check the old README_
#### forRoot/forFeature
To configure the plugin the first time (
main.module.ts) the forRoot() method is used.
It builds the basis for all further uses of the plugin.
But you have the possibility to overwrite the entire or just parts of the configuration in any (sub-)module.##### forRoot
To overwrite the entire configuration use:
`
FirebaseUIModule.forRoot(firebaseUiAuthConfig: NativeFirebaseUIAuthConfig)
`
##### forFeature
To overwrite just parts of the configuration use:
`
FirebaseUIModule.forFeature(firebaseUiAuthConfig: NativeFirebaseUIAuthConfig)
`
This will use the in forRoot provided configuration and overwrite just the newly provided values.
$3
`typescript
this.angularFireAuth.authState.subscribe(this.firebaseAuthChangeListener);private firebaseAuthChangeListener(response) {
// if needed, do a redirect in here
if (response) {
console.log('Logged in :)');
} else {
console.log('Logged out :(');
}
}
`
Don't forget to unsubscribe at the end.$3
`html
(signInSuccessWithAuthResult)="successCallback($event)"
(signInFailure)="errorCallback($event)"
(uiShown)="uiShownCallback()">
``typescript
successCallback(signInSuccessData: FirebaseUISignInSuccessWithAuthResult) {
...
}errorCallback(errorData: FirebaseUISignInFailure) {
...
}
uiShownCallback() {
...
}
`$3
`typescript
constructor(private firebaseuiAngularLibraryService: FirebaseuiAngularLibraryService) {
firebaseuiAngularLibraryService.firebaseUiInstance.disableAutoSignIn();
}
`Sample
There is a sample project in the root folder.
* Just replace the firebase config in
src\environments\environment.ts.
* Run npm install
* Run npm run build-lib
* Run ng serveDevelopment
The library sources are in
projects/firebaseui/angular/library.To generate all
.js, .d.ts and *.metadata.json files:`bash
$ npm run build-lib
`To lint all
*.ts files:`bash
$ npm run lint
`There are test files, but they are empty at the moment.
Troubleshoot
$3
The UI only gets rendered if the user isn't signed in. So if the UI isn't shown, sign out the user via angular-fire.$3
`
ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'firebase/index' in '...'
ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'firebaseui/dist/index' in '...'
`Use the firebase and firebaseui instances exposed by the plugin:
import {..., firebase, firebaseui} from '@speakylink/firebaseui-angular';$3
If you have added the css to the angular.json but nothing happened. Try to restart the server (Ctrl-C and ng serve)$3
This is a know issue in the firebase project. To fix that (for now), do that:
npm install promise-polyfill --save-exact$3
Put this into your styles.scss file:`
@supports (-webkit-appearance:none) {
.mdl-progress:not(.mdl-progress--indeterminate):not(.mdl-progress--indeterminate) > .auxbar,
.mdl-progress:not(.mdl-progress__indeterminate):not(.mdl-progress__indeterminate) > .auxbar {
mask: url(/assets/images/buffer.svg?embed) !important;
}
}
`and put a
buffer.svg file into assets/images`.MIT © Raphael Jenni