GithubHelp home page GithubHelp logo

turnono / ionicfirebaseui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexnu/ionicfirebaseui

0.0 2.0 0.0 1.6 MB

Sample integration of FirebaseUI into Ionic 2

JavaScript 8.33% TypeScript 47.23% HTML 23.44% CSS 20.99%

ionicfirebaseui's Introduction

FirebaseUI for web - Ionic demo

This is a demo Ionic project using FirebaseUI-web.

Firebase console configuration:

To properly configure your Firebase Project please follow all the instructions from the Set up Firebase Authentication for Cordova section at the following link:

https://firebase.google.com/docs/auth/web/cordova

Configuring sign-in providers

To use FirebaseUI to authenticate users you first need to configure each provider you want to use in their own developer app settings. Please read the Before you begin section of Firebase Authentication at the following links:

Note

Phone number is currently not supported for Ionic/Cordova environments.

Run app locally:

$ npm install
$ ionic serve

Note

ionic lab or ionic serve --lab does not work with FirebaseUI, you will have to use ionic serve instead.

Add FirebaseUI to your own Ionic project:

After setting up Firebase console as described above, please follow the next steps:

Install firebase and firebaseui dependencies:

$ npm install firebase --save
$ npm install firebaseui --save

Setup firebaseui css to be visible to the app:

  • First the css file has to be copied to www/build folder during every build. For that you need to create file config/copy.config.js with the following code:
module.exports = {
  copyFirebaseUiCss: {
    src: ['./node_modules/firebaseui/dist/firebaseui.css'],
    dest: '{{BUILD}}'
  }
}
  • And add the following lines to your package.json:
"config": {
  "ionic_copy": "./config/copy.config.js"
}
  • Then add the following line to src/index.html
<link href="build/firebaseui.css" rel="stylesheet">

For android set launchMode to singleInstance

By adding the following line to config.xml:

<preference name="AndroidLaunchMode" value="singleInstance" />

This is needed for Google Provider because sometimes after authentication a new instance of the app is created resulting in never successfully authenticating. The issue does not occur on iOS devices.

Create FirebaseUIProvider

There should only be a single instance of firebaseui for the whole app, so it is a good idea to create a provider and save the instance there:

@Injectable()
export class FirebaseuiProvider {

  ui: any;

  constructor() {
    // Initialize the FirebaseUI Widget using Firebase.
    this.ui = new firebaseui.auth.AuthUI(firebase.auth());
  }

}

Add FirebaseUI to any page you like

See example at src/pages/login/login.ts.

ionicfirebaseui's People

Contributors

alexnu avatar

Watchers

James Cloos avatar Abdullah Abrahams avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.