@@ -33,8 +33,9 @@ and [Web](https://github.com/firebase/firebaseui-web/).
33
33
1 . [ Configuration] ( #configuration )
34
34
1 . [ Provider config] ( #identity-provider-configuration )
35
35
1 . [ Usage instructions] ( #using-firebaseui-for-authentication )
36
- 1 . [ Sign in] ( #sign-in )
36
+ 1 . [ AuthUI sign- in] ( #authui- sign-in )
37
37
1 . [ Handling responses] ( #handling-the-sign-in-response )
38
+ 1 . [ Silent sign-in] ( #silent-sign-in )
38
39
1 . [ Sign out] ( #sign-out )
39
40
1 . [ Account deletion] ( #deleting-accounts )
40
41
1 . [ Auth flow chart] ( #authentication-flow-chart )
@@ -169,7 +170,7 @@ If an alternative app instance is required, call
169
170
` AuthUI.getInstance(app) ` instead, passing the appropriate ` FirebaseApp `
170
171
instance.
171
172
172
- ### Sign in
173
+ ### AuthUI sign- in
173
174
174
175
If a user is not currently signed in, as can be determined by checking
175
176
` auth.getCurrentUser() != null ` (where ` auth ` is the ` FirebaseAuth ` instance
@@ -352,7 +353,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
352
353
showSnackbar(R . string. no_internet_connection);
353
354
return ;
354
355
}
355
-
356
+
356
357
showSnackbar(R . string. unknown_error);
357
358
Log . e(TAG , " Sign-in error: " , response. getError());
358
359
}
@@ -399,6 +400,40 @@ if (metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp()) {
399
400
}
400
401
```
401
402
403
+ ### Silent sign-in
404
+
405
+ If a user is not currently signed in, then a silent sign-in process can be started first before
406
+ displaying any UI to provide a seamless experience. Silent sign-in uses saved Smart Lock credentials
407
+ and returns a successful ` Task ` only if the user has been fully signed in with Firebase.
408
+
409
+ Here's an example of how you would use silent sign-in paired with anonymous users to get your users
410
+ up and running as fast as possible:
411
+
412
+ ``` java
413
+ List<IdpConfig > providers = getSelectedProviders();
414
+ AuthUI . getInstance(). silentSignIn(this , providers)
415
+ .continueWithTask(new Continuation<AuthResult , Task<AuthResult > > () {
416
+ @Override
417
+ public Task<AuthResult > then (@NonNull Task<AuthResult > task ) {
418
+ if (task. isSuccessful()) {
419
+ return task;
420
+ } else {
421
+ // Ignore any exceptions since we don't care about credential fetch errors.
422
+ return FirebaseAuth . getInstance(). signInAnonymously();
423
+ }
424
+ }
425
+ }). addOnCompleteListener(new OnCompleteListener<AuthResult > () {
426
+ @Override
427
+ public void onComplete (@NonNull Task<AuthResult > task ) {
428
+ if (task. isSuccessful()) {
429
+ // Signed in! Start loading data
430
+ } else {
431
+ // Uh oh, show error message
432
+ }
433
+ }
434
+ });
435
+ ```
436
+
402
437
### Sign out
403
438
404
439
With the integrations provided by AuthUI, signing out a user is a multi-stage process:
0 commit comments