티스토리 뷰

 

github.com/firebase/firebaseui-web

 

firebase/firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices. - firebase/f...

github.com

언어 지원범위 - https://github.com/firebase/firebaseui-web/blob/master/LANGUAGES.md

  1. git clone https://github.com/firebase/firebaseui-web
  2. npm install
  3. npm run build build-js-ko
  4. npm run build build-npm-ko
  5. firebaseui__ko.js, npm__ko.js 두 파일을 적용할 프로젝트/node_modules/firebaseui/dist로 복사
  6. import * as firebaseui from 'firebaseui/dist/npm__ko';

 

import React, { Component } from 'react';
import firebase from 'firebase';
//import * as firebaseui from 'firebaseui'
import * as firebaseui from 'firebaseui/dist/npm__ko';

class FirebaseContainer extends Component {
  componentDidMount() {

    const firebaseConfig = {
      apiKey: "AIzaSyBmD4v0PtxxZEeTNhHRaa4aAHeCdcxX0us",
      authDomain: "phoneauthenticationreact.firebaseapp.com",
      databaseURL: "https://phoneauthenticationreact.firebaseio.com",
      projectId: "phoneauthenticationreact",
      storageBucket: "phoneauthenticationreact.appspot.com",
      messagingSenderId: "511189683965",
      appId: "1:511189683965:web:ad29efffb76afdd6627894"
    };

    const fbase = firebase.initializeApp(firebaseConfig);
    const uiConfig = {
      //signInSuccessUrl: 'http://localhost:3000/', //This URL is used to return to that page when we got success response for phone authentication.
      signInOptions: [{
        provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
        defaultCountry: 'KR',
        whitelistedCountries: ['KR', '+82'],
        defaultNationalNumber: '01011112222',
      }
      ],
      callbacks: {
        signInSuccessWithAuthResult: function (authResult, redirectUrl) {
          // Handle the result
          console.log(authResult, redirectUrl);
          return false;
        },
      }
    };
    
    const ui = new firebaseui.auth.AuthUI(firebase.auth());
    ui.start('#firebaseui-auth-container', uiConfig);
  }
  render() {
    return (
      <>
        <h2>PHONE AUTHENTICATION</h2>
        <div id="firebaseui-auth-container"></div>
      </>
    )
  }
}

export default FirebaseContainer;

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함