1 |
|
2 | [![oijusti](https://circleci.com/gh/oijusti/react-native-firebaseui-auth.svg?style=svg)](https://circleci.com/gh/oijusti/react-native-firebaseui-auth)
|
3 |
|
4 | [![Build Status](https://travis-ci.org/oijusti/react-native-firebaseui-auth.svg?branch=master)](https://travis-ci.org/oijusti/react-native-firebaseui-auth)
|
5 |
|
6 | [prs]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
7 | [prs-url]: https://github.com/oijusti/react-native-firebaseui-auth#contributing
|
8 |
|
9 | [![npm version](https://badge.fury.io/js/react-native-firebaseui-auth.svg)](https://www.npmjs.com/package/react-native-firebaseui-auth) [![PR's welcome][prs]][prs-url]
|
10 |
|
11 | <a href="https://npmcharts.com/compare/react-native-firebaseui-auth?minimal=true">
|
12 | <img src="https://img.shields.io/npm/dt/react-native-firebaseui-auth?color=46c71f"/>
|
13 | </a>
|
14 |
|
15 | <a href="https://npmcharts.com/compare/react-native-firebaseui-auth?minimal=true">
|
16 | <img src="https://img.shields.io/npm/dm/react-native-firebaseui-auth.svg">
|
17 | </a>
|
18 |
|
19 | <a href="https://packagephobia.now.sh/result?p=react-native-firebaseui-auth">
|
20 | <img src="https://packagephobia.now.sh/badge?p=react-native-firebaseui-auth" alt="install size">
|
21 | </a>
|
22 |
|
23 |
|
24 | # react-native-firebaseui-auth
|
25 |
|
26 | Easily add sign-in to your React Native app with FirebaseUI
|
27 |
|
28 | <div align="left">
|
29 | <p float="left">
|
30 | <img src="https://raw.githubusercontent.com/oijusti/react-native-firebaseui-auth/HEAD/firebaseui-android.png" width="150"/>
|
31 | <img src="https://raw.githubusercontent.com/oijusti/react-native-firebaseui-auth/HEAD/firebaseui-ios.png" width="150"/>
|
32 | </p>
|
33 | </div>
|
34 |
|
35 | ## Getting started
|
36 |
|
37 | ### Add Firebase to your project
|
38 |
|
39 | #### Android:
|
40 |
|
41 | 1. Follow the [Android setup guide](https://firebase.google.com/docs/android/setup)
|
42 | 2. Follow the [sign-in methods guide](https://firebase.google.com/docs/auth/android/firebaseui#set_up_sign-in_methods)
|
43 |
|
44 | #### iOS:
|
45 | 1. Follow the [iOS setup guide](https://firebase.google.com/docs/ios/setup)
|
46 |
|
47 | 2. Add FirebaseUI to your Podfile:
|
48 |
|
49 | ```
|
50 | pod 'FirebaseUI'
|
51 | ```
|
52 | Run ` $ pod update`
|
53 | 3. Follow the [sign-in methods guide](https://firebase.google.com/docs/auth/ios/firebaseui#set_up_sign-in_methods)
|
54 |
|
55 | ### Installation
|
56 |
|
57 | `$ npm install react-native-firebaseui-auth --save`
|
58 |
|
59 | or
|
60 |
|
61 | `$ yarn add react-native-firebaseui-auth`
|
62 |
|
63 |
|
64 | ### Linking (RN >= 0.60 skip this step)
|
65 |
|
66 | RN <= 0.59 only
|
67 |
|
68 | #### Automatic
|
69 |
|
70 | `$ react-native link react-native-firebaseui-auth`
|
71 |
|
72 | #### Manual
|
73 |
|
74 | #### iOS
|
75 |
|
76 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
77 | 2. Go to `node_modules` ➜ `react-native-firebaseui-auth` and add `RNFirebaseuiAuth.xcodeproj`
|
78 | 3. In XCode, in the project navigator, select your project. Add `libRNFirebaseuiAuth.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
79 | 4. Run your project (`Cmd+R`)
|
80 |
|
81 | #### Android
|
82 |
|
83 | 1. Open up `android/app/src/main/java/[...]/MainApplication.java`
|
84 | - Add `import com.oijusti.firebaseuiauth.RNFirebaseuiAuthPackage;` to the imports at the top of the file
|
85 | - Add `new RNFirebaseuiAuthPackage()` to the list returned by the `getPackages()` method
|
86 | 2. Append the following lines to `android/settings.gradle`:
|
87 | ```
|
88 | include ':react-native-firebaseui-auth'
|
89 | project(':react-native-firebaseui-auth').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebaseui-auth/android')
|
90 | ```
|
91 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
92 | ```
|
93 | implementation project(':react-native-firebaseui-auth')
|
94 | ```
|
95 |
|
96 |
|
97 | ## Usage
|
98 |
|
99 | ```javascript
|
100 | import Auth from 'react-native-firebaseui-auth';
|
101 |
|
102 | ...
|
103 |
|
104 | const config = {
|
105 | providers: [
|
106 | 'anonymous',
|
107 | 'facebook',
|
108 | 'google',
|
109 | 'email',
|
110 | 'phone',
|
111 | 'apple',
|
112 | 'yahoo',
|
113 | 'github',
|
114 | 'twitter',
|
115 | 'microsoft'
|
116 | ],
|
117 | tosUrl: 'https://example.com/tos.htm',
|
118 | privacyPolicyUrl: 'https://example.com/privacypolicy.htm',
|
119 | };
|
120 |
|
121 | Auth.signIn(config)
|
122 | .then(user => console.log(user))
|
123 | .catch(err => console.log(err));
|
124 |
|
125 | ...
|
126 |
|
127 | Auth.getCurrentUser().then(user => console.log(user));
|
128 |
|
129 | ...
|
130 |
|
131 | Auth.signOut().then(res => console.log(res));
|
132 |
|
133 | ...
|
134 |
|
135 | Auth.delete().then(res => console.log(res));
|
136 |
|
137 | ...
|
138 | ```
|
139 |
|
140 | ### Returns: `user`
|
141 |
|
142 | Field | Type | Description |
|
143 | --- | --- | --- |
|
144 | uid |`string`| The provider's user ID for the user. |
|
145 | displayName |`string`| The name of the user. |
|
146 | photoURL |`string`| The URL of the user's profile photo. |
|
147 | email |`string`| Indicates the email address associated with this user ~~has been verified~~. |
|
148 | phoneNumber |`string`| A phone number associated with the user. |
|
149 | providerId |`string`| The provider identifier. |
|
150 | isNewUser |`boolean`| Indicates whether or not the current user was signed in for the first time. |
|
151 | creationTimestamp |`number`| Stores the timestamp at which this account was created as dictated by the server clock in milliseconds since epoch. |
|
152 | lastSignInTimestamp |`number`| Stores the last signin timestamp as dictated by the server clock in milliseconds since epoch. |
|
153 |
|
154 | ## Example Project
|
155 |
|
156 | Create a project in the [Firebase Console](https://console.firebase.google.com) and add apps for Android and iOS. Then enable Email/Password provider in Authentication.
|
157 |
|
158 | #### Android
|
159 | Make sure you type `com.example.app` in the `Android package name` field.
|
160 |
|
161 | Download the file `google-services.json` in the android/app folder.
|
162 |
|
163 | #### iOS
|
164 | Make sure you type `com.example.app` in the `iOS bundle ID` field.
|
165 |
|
166 | Download the file ``GoogleService-Info.plist`` in the ios/example folder and add it into the project using xcode.
|
167 |
|
168 | Update pods `$ pod install`
|
169 |
|
170 | ## Contributing
|
171 |
|
172 | Feel free to report bugs, ask questions and submit a PR.
|
173 |
|
174 | If this is your first open source contribution, please take a look at this [guide](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github) .
|
175 |
|
176 | ## Sponsors
|
177 |
|
178 | Become a sponsor to support the further development of this and other libraries.
|
179 |
|
180 | <div align="left">
|
181 | <a href="https://oiradio.co" target="_blank"><img src="https://oiradio.co/assets/images/stations/i/i0.png"></a>
|
182 | </div>
|
183 |
|
184 | Or give me a star ✭ if you like it!
|
185 |
|
186 | ## License
|
187 |
|
188 | (MIT)
|
189 |
|
\ | No newline at end of file |