Explore curated features and services of Firebase from Authentication, Realtime Database, Cloud Firestore, Cloud Storage, etc. This session will highlight the de facto features of Firebase used to start building a full-fledged working Android app.
FEU Institute of Technology • Currently working for a British financial software • Freelance Android Developer, 2019-present • Open-source contributor (Android, Google, Firebase, Tinder, Telegram, Signal, etc.) • I love building things around Android and the JVM
the user's ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. private val signInOptions: GoogleSignInOptions by lazy { GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build() } private val googleSignInContract = registerForActivityResult( ActivityResultContracts.StartActivityForResult() ) { result -> if (result.resultCode != RESULT_OK) { Logger.e("GoogleSignInContract: failed") return@registerForActivityResult } val signInTask = GoogleSignIn.getSignedInAccountFromIntent(result.data) try { val googleSignInAccount = signInTask.getResult(ApiException::class.java) signInFirebaseWithGoogleAccount(googleSignInAccount) } catch (e: ApiException) { // consume error message and display to the user. } }
{ if (it.isSuccessful) { navigateToMainScreen() } else { // display error message } } } // invoke Google sign in button to authenticate with Firebase Auth. binding.signInWithGoogleBtn.setOnClickListener { val signInClient = GoogleSignIn.getClient(requireContext(), signInOptions) googleSignInContract.launch(signInClient.signInIntent) } // See documentation at https://firebase.google.com/docs/auth/android/google-signin
into the FacebookSdk from // an Activity's or Fragment's onActivityResult() method. private val callbackManager = CallbackManager.Factory.create() // Since we are not going to use Facebook’s default Login UI Button, // therefore, we will manually configure our LoginManager logic to our // custom LoginButton UI. private val loginManager by lazy { LoginManager.getInstance().apply { setLoginBehavior(LoginBehavior.DIALOG_ONLY) setAuthType(ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE) registerCallback(callbackManager, facebookCallback) … } } // A callback listener for retrieving Facebook login result private val facebookCallback = object : FacebookCallback<LoginResult> { override fun onSuccess(result: LoginResult) { signInFirebaseWithFacebookAccessToken(result.accessToken) } // comment out for abbrev. }