Git Product home page Git Product logo

react-native-firebase-auth's Introduction

This is the react-native implementation of https://github.com/SolidStateGroup/simple-firebase-auth

React Native Firebase Auth

Gitter

Simplified Firebase authentication for React Native projects with support for Facebook & Google login.

Using this module alongside Firebase means there is no need to write and host any backend code to handle users logging in to your app.

Use our project starter repository (https://github.com/SolidStateGroup/firebase-project-starter) to help you get started setting up your own Firebase project.

Installation

$ npm install --save react-native-firebase-auth

Note: If you use React Native < v0.39 or you are already using react-native-google-signin then stick with v0.0.11 (npm install [email protected] --save)

Project Setup

$ npm install --save firebase react-native-facebook-login react-native-google-sign-in

You will need fully setup both of the below social platform dependencies (react-native-google-sign-in and react-native-facebook-login).

https://github.com/joonhocho/react-native-google-sign-in#getting-started https://github.com/magus/react-native-facebook-login#setup

You will need to initialise Firebase within your app in the usual way. See https://firebase.google.com/docs/web/setup

Usage

import FireAuth from 'react-native-firebase-auth';

constructor(props) {
  super(props);
  FireAuth.init({iosClientId: <IOS_CLIENT_ID>}); // This is the CLIENT_ID found in your Google services plist.
}

componentDidMount() {
  FireAuth.setup(this.onLogin, this.onUserChange, this.onLogout, this.emailVerified, this.onError);
}

register = () => {
  const { email, password, firstName, lastName } = this.state;
  FireAuth.register(email, password, { firstName, lastName });
}

login = () => {
  FireAuth.login(this.state.email, this.state.password);
}

loginAnonymously = () => {
  FireAuth.loginAnonymously();
}

facebookLogin() {
  FireAuth.facebookLogin();
}

googleLogin() {
  FireAuth.googleLogin();
}

logout() {
  FireAuth.logout();
}

update () => {
  FireAuth.update({
    firstName: this.state.firstName,
    lastName: this.state.lastName
  }).then(() => {
    ...
  }).catch(err => {
    ...
  });
}

resetPassword () => {
  FireAuth.resetPassword(this.state.email)
    .then(() => {
      ...
    })
    .catch(err => {
      ...
    });
}

updatePassword () => {
  FireAuth.updatePassword(this.state.password)
    .then(() => {
      ...
    })
    .catch(err => {
      ...
    });
}

Credits

https://github.com/magus/react-native-facebook-login

https://github.com/joonhocho/react-native-google-sign-in

Getting Help

If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search existing issues in order to prevent duplicates.

Contributing

For more information about contributing PRs, please see our Contribution Guidelines.

Get in touch

If you have any questions about our projects you can email [email protected].

react-native-firebase-auth's People

Contributors

altescape avatar dabeeeenster avatar kyle-ssg avatar lukefanning 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.