Skip to content

Commit f6405d4

Browse files
committed
Merge branch 'abe-0.3.0' of github.com:firebase/FirebaseUI-Android into abe-0.3.0
2 parents 916a4a9 + de2f148 commit f6405d4

File tree

1 file changed

+58
-12
lines changed

1 file changed

+58
-12
lines changed

README.md

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ You can also add the library dependency directly to your app's gradle.build file
2626

2727
```
2828
dependencies {
29-
compile 'com.firebaseui:firebase-ui:0.3.0'
29+
compile 'com.firebaseui:firebase-ui:0.2.2'
3030
}
3131
```
3232

3333
After the project is synchronized, we're ready to start using Firebase functionality in our app.
3434

3535
## Using FirebaseUI for Authentication
3636

37-
FirebaseUI has a wonderful built-in login dialog which you can use to provide a headful UI for your users to authenticate with.
37+
FirebaseUI has a built-in dialog that you can use pop up to allow your users to log in.
3838

3939
![FirebaseUI Login Dialog](doc-images/mdialog.png "FirebaseUI Login Dialog")
4040

@@ -43,15 +43,18 @@ To use FirebaseUI to authenticate users we need to do a few things:
4343
1. Add our Facebook/Twitter/Google keys to strings.xml
4444
2. Add our activities to our AndroidManifest.xml
4545
3. Inherit from FirebaseLoginBaseActivity
46-
4. Call showFirebaseLoginDialog();
46+
4. Enable authentication providers
47+
5. Call showFirebaseLoginDialog();
48+
49+
We'll go into each of these steps below.
4750

4851
### Add our Facebook/Twitter/Google keys to strings.xml
4952

5053
Open your `res/values/strings.xml` file and add the following lines, replacing `[VALUE]` with your key.
5154

52-
Keep in mind, these are all optional. If you don't plan to use Twitter/Facebook/Google login, you can leave those values empty or remove the string definition entirely.
55+
Keep in mind, these are all optional. You only have to provide values for the providers you plan to use.
5356

54-
*Note:* If you're not using *all* available providers, you'll need to manually create and manage your `FirebaseLoginDialog` and specify the enabled providers as demonstrated in [`FirebaseLoginBaseActivity.java`](library/src/main/java/com/firebase/ui/auth/core/FirebaseLoginBaseActivity.java).
57+
[`FirebaseLoginBaseActivity.java`](library/src/main/java/com/firebase/ui/auth/core/FirebaseLoginBaseActivity.java).
5558

5659
```xml
5760
<string name="facebook_app_id">[VALUE]</string>
@@ -62,9 +65,9 @@ Keep in mind, these are all optional. If you don't plan to use Twitter/Facebook/
6265

6366
### Add our activities to our AndroidManifest.xml
6467

65-
Open your `manifests/AndroidManifest.xml` file.
68+
Open your `manifests/AndroidManifest.xml` file. This will allow Android to recognize the various activities that FirebaseUI exposes.
6669

67-
Add the following to your `<application>` tag.
70+
If you're using Twitter authentication, add the following to your `<application>` tag.
6871

6972
```xml
7073
<!-- Twitter Configuration -->
@@ -75,7 +78,11 @@ Add the following to your `<application>` tag.
7578
<meta-data
7679
android:name="com.firebase.ui.TwitterSecret"
7780
android:value="@string/twitter_app_secret"/>
81+
```
7882

83+
If you're using Facebook authentication, add the following to your `<application>` tag.
84+
85+
```xml
7986
<!-- Facebook Configuration -->
8087
<activity
8188
android:name="com.facebook.FacebookActivity"
@@ -103,28 +110,67 @@ This activity should implement a few methods so your application can react to ch
103110
public class MainActivity extends FirebaseLoginBaseActivity {
104111
...
105112
@Override
106-
public Firebase getFirebaseRef() {}
113+
public Firebase getFirebaseRef() {
114+
// TODO: Return your Firebase ref
115+
}
107116

108117
@Override
109-
public void onFirebaseLoginSuccess(AuthData authData) {}
118+
public void onFirebaseLoginSuccess(AuthData authData) {
119+
// TODO: Handle successful login
120+
}
110121

111122
@Override
112-
public void onFirebaseLogout() {}
123+
public void onFirebaseLogout() {
124+
// TODO: Handle logout
125+
}
113126

114127
@Override
115-
public void onFirebaseLoginProviderError(FirebaseLoginError firebaseError) {}
128+
public void onFirebaseLoginProviderError(FirebaseLoginError firebaseError) {
129+
// TODO: Handle an error from the authentication provider
130+
}
116131

117132
@Override
118-
public void onFirebaseLoginUserError(FirebaseLoginError firebaseError) {}
133+
public void onFirebaseLoginUserError(FirebaseLoginError firebaseError) {
134+
// TODO: Handle an error from the user
135+
}
119136
}
120137
```
121138

139+
### Enable Authentication Providers
140+
141+
Now that our activity is set up, we can enable authentication providers. The FirebaseUI login prompt will only display providers you enable here, so don't worry if you don't want to use them all!
142+
143+
```java
144+
public class MainActivity extends FirebaseLoginBaseActivity {
145+
...
146+
@Override
147+
protected void onStart() {
148+
super.onStart();
149+
// All providers are optional! Remove any you don't want.
150+
setEnabledAuthProvider(SocialProvider.facebook);
151+
setEnabledAuthProvider(SocialProvider.twitter);
152+
setEnabledAuthProvider(SocialProvider.google);
153+
setEnabledAuthProvider(SocialProvider.password);
154+
}
155+
```
156+
157+
122158
### Call showFirebaseLoginDialog();
123159

124160
You're now ready to display the login dialog!
125161
126162
Simply call `showFirebaseLoginPrompt()` from within your activity and you'll see the dialog!
127163

164+
For example, if we had a mLoginButton, we could display the dialog when the user clicks the button.
165+
```java
166+
mLoginButton.setOnClickListener(new View.OnClickListener() {
167+
@Override
168+
public void onClick(View view) {
169+
showFirebaseLoginPrompt();
170+
}
171+
});
172+
```
173+
128174

129175
## Using FirebaseUI to Populate a ListView
130176

0 commit comments

Comments
 (0)