FirebaseUser user = firebaseAuth.getCurrentUser(); assert user != null; And what does assert mean?
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); Absolutely no difference. To get a FirebaseAuth object, you need to call the static getInstance() method. Correspondingly, the difference between FirebaseUser user = firebaseAuth.getCurrentUser(); and FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); only that in the first case we save the object into a variable and in the second there is no.
Assert - not sure where you got it from, but its Java equivalent will look like this
if (user != null) { // User is signed in Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out Log.d(TAG, "onAuthStateChanged:signed_out"); } Assert from eng. to expect. Accordingly, we need this check in order to continue to perform actions on this variable.
Source: https://ru.stackoverflow.com/questions/629431/
All Articles
firebaseAuthvariablefirebaseAuth? If it is taken asFirebaseAuth firebaseAuth = FirebaseAuth.getInstance(), then there will be no difference. The design ofassertpulls on a separate question. - Regent