Easily add sign-in to your React Native app with FirebaseUI
Follow the iOS setup guide
Add FirebaseUI to your Podfile:
pod 'FirebaseUI'
Run $ pod update
Follow the sign-in methods guide
$ npm install react-native-firebaseui-auth --save
or
$ yarn add react-native-firebaseui-auth
RN <= 0.59 only
$ react-native link react-native-firebaseui-auth
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-firebaseui-auth
and add RNFirebaseuiAuth.xcodeproj
libRNFirebaseuiAuth.a
to your project’s Build Phases
➜ Link Binary With Libraries
Cmd+R
)android/app/src/main/java/[...]/MainApplication.java
import com.oijusti.firebaseuiauth.RNFirebaseuiAuthPackage;
to the imports at the top of the filenew RNFirebaseuiAuthPackage()
to the list returned by the getPackages()
methodAppend the following lines to android/settings.gradle
:
include ':react-native-firebaseui-auth'
project(':react-native-firebaseui-auth').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebaseui-auth/android')
Insert the following lines inside the dependencies block in android/app/build.gradle
:
implementation project(':react-native-firebaseui-auth')
import Auth from 'react-native-firebaseui-auth';
...
const config = {
providers: [
'facebook',
'google',
'email',
'phone',
'apple',
'yahoo',
'github',
'twitter',
'microsoft'
],
tosUrl: 'https://example.com/tos.htm',
privacyPolicyUrl: 'https://example.com/privacypolicy.htm',
};
Auth.signIn(config).then(user => console.log(user));
...
Auth.signOut().then(resp => console.log(resp));
...
Auth.getCurrentUser().then(user => console.log(user));
...
user
Field | Type | Description |
---|---|---|
uid | string |
The provider’s user ID for the user. |
displayName | string |
The name of the user. |
photoURL | string |
The URL of the user’s profile photo. |
string |
Indicates the email address associated with this user |
|
phoneNumber | string |
A phone number associated with the user. |
providerId | string |
The provider identifier. |
isNewUser | boolean |
Indicates whether or not the current user was signed in for the first time. |
creationTimestamp | int |
Stores the timestamp at which this account was created as dictated by the server clock in milliseconds since epoch. |
lastSignInTimestamp | int |
Stores the last signin timestamp as dictated by the server clock in milliseconds since epoch. |
Create a project in the Firebase Console and add apps for Android and iOS. Then enable Email/Password provider in Authentication.
Make sure you type com.example.app
in the Android package name
field.
Download the file google-services.json
in the android/app folder.
Make sure you type com.example.app
in the iOS bundle ID
field.
Download the file GoogleService-Info.plist
in the ios/example folder and add it into the project using xcode.
Update pods $ pod install
Feel free to report bugs, ask questions and submit a PR.
If this is your first open source contribution, please take a look at this guide .
Author: oijusti
Source Code: https://github.com/oijusti/react-native-firebaseui-auth
#react-native #react #mobile-apps