Introduction to FirebaseUI Auth authentication

FirebaseUI Auth login માટેનો fast path છે: prebuilt, drop-in sign-in flow, જેમાં providersની list આપીને launch કરો; તે ready-made screens બતાવે છે, આખી process handle કરે છે અને result પાછો આપે છે, એટલે login UI જાતે બનાવવાની જરૂર નથી.

10 min read · 7 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Login UI બનાવ્યા વગર login

Appમાં sign-in add કરવું સામાન્ય રીતે login અને registration screens design કરવાથી શરૂ થાય છે. Buttons wire કરવા, input validate કરવા, errors બતાવવા જેવી ઘણી મહેનત પડે છે. FirebaseUI Auth shortcut આપે છે: complete, prebuilt sign-in flow, જે તમે appમાં drop-in કરી શકો છો.

તમે કયા sign-in methods offer કરવા છે તે કહો, FirebaseUI launch કરો, અને તે polished login screens બતાવીને આખી process handle કરે છે. અંતે result તમને પાછો મળે છે. આ lesson fast path સમજાવે છે. Next lessonમાં alternative, એટલે કે own UI સાથે Firebase SDK direct call કરવું, શીખશો.

Theory

FirebaseUI Auth કેવી રીતે કામ કરે છે

Idea simple છે. તમે configuration બનાવો છો: offer કરવા માંગતા providersની list, જેમ કે email/password, Google વગેરે. આ configuration સાથે FirebaseUIનું sign-in Intent launch કરો. પછી FirebaseUI આખી process સંભાળે છે: ready-made screens બતાવે છે, userને register અથવા login કરવા દે છે, દરેક providerનો flow ચલાવે છે, errors handle કરે છે અને અંતે result પાછો activityને આપે છે.

Success પછી user FirebaseAuthમાં sign in થયેલો હોય છે, જાણે તમે બધું manually કર્યું હોય. તેથી auth.currentUser set થાય છે. તમે લગભગ કોઈ UI code લખ્યો નથી; FirebaseUI heavy lifting કરે છે, છતાં અંદર standard Firebase Authentication જ વપરાય છે.

Practical

FirebaseUI sign-in flow launch કરવો

// Choose which sign-in methods to offer
val providers = listOf(
    AuthUI.IdpConfig.EmailBuilder().build(),
    AuthUI.IdpConfig.GoogleBuilder().build(),
)

// Build the prebuilt sign-in Intent and launch it
val signInIntent = AuthUI.getInstance()
    .createSignInIntentBuilder()
    .setAvailableProviders(providers)
    .build()

signInLauncher.launch(signInIntent)   // FirebaseUI shows the login screens
// The result comes back to your registered ActivityResult callback.

Formula

હમણાં convenience, control ઓછું

FirebaseUI Authની strength speed અને correctness છે: થોડા linesમાં working, best-practice login flow મળે છે, જેમાં sensible screens, validation, error handling અને multiple providersનો support હોય છે.

Trade-off control છે: screens FirebaseUI પ્રમાણે દેખાશે અને flow પણ તે જ આપશે. જો appને fully custom login look અથવા unusual behaviour જોઈએ, તો next lesson પ્રમાણે SDK direct વાપરવો. એટલે standard login ઝડપથી અને સારી રીતે જોઈએ તથા ready-made experience સ્વીકાર્ય હોય ત્યારે FirebaseUI ideal છે.

Quiz

Login screens જાતે બનાવવાને બદલે FirebaseUI Auth વાપરવાનો મુખ્ય લાભ શું છે?

  1. App કોઈ internet વગર ચાલે છે
  2. Minimal codeથી complete prebuilt sign-in flow, screens, multiple providers અને error handling મળે છે
  3. Firebase projectની જરૂર રહેતી નથી
  4. Passwords તમારા માટે plain textમાં store કરે છે
Show the answer

Minimal codeથી complete prebuilt sign-in flow, screens, multiple providers અને error handling મળે છે

FirebaseUI Auth ready-made, best-practice sign-in flow આપે છે: polished screens, multiple providersનો support અને registration, login તથા errorsનું built-in handling. તેથી ખૂબ ઓછા codeથી authentication add થાય છે. Option A ખોટું છે: Firebase સુધી પહોંચવા authenticationને network જોઈએ; FirebaseUI offline authentication બનાવતું નથી. Option C ખોટું છે: Firebase project અને configuration હજી જરૂરી છે; FirebaseUI Firebase Auth પર build થાય છે. Option D ખોટું અને unsafe છે: Firebase passwords plain textમાં store કરતું નથી; credentials securely handle થાય છે. Main benefit minimal effortમાં complete login experience છે, જેના બદલામાં UI control થોડું ઓછું મળે છે.

Think first

ક્યારે FirebaseUI ન વાપરીને SDK direct વાપરવો?

FirebaseUI convenient છે. Developer ક્યારે તેને skip કરીને Firebase SDK direct call કરશે? પછી tap.

Show the answer

જ્યારે login experienceના look, flow અથવા behaviour પર સંપૂર્ણ CONTROL જોઈએ અને FirebaseUIના prebuilt screens તે control આપી ન શકે ત્યારે FirebaseUI skip કરશો. FirebaseUI convenience માટે control trade કરે છે: fixed, sensible screens અને standard flow આપે છે, જે મોટાભાગના apps માટે યોગ્ય છે.

પરંતુ કેટલીક appsને specific brand look, custom layouts, animations અથવા પોતાના copyવાળી screens જોઈએ છે. કેટલીક appsમાં extra steps, custom validation messages, login સાથે onboarding જોડવું, bespoke UI સાથે tight integration અથવા દરેક step પર પોતાનું analytics અને error handling જોઈએ છે. આવા સમયે Firebase Authentication SDK DIRECTLY call કરો: own login અને registration screens બનાવો અને createUserWithEmailAndPassword તથા signInWithEmailAndPassword જેવી methods જાતે invoke કરો.

તેમાં વધુ code અને વધુ responsibility આવે છે: UI design કરવું, states handle કરવી અને errors બતાવવાં. બદલામાં experience પર complete freedom મળે છે. Engineering trade-off સરળ છે: standard login ઝડપથી જોઈએ તો FirebaseUI; custom look અથવા unusual flow જોઈએ અને UI બનાવવાની તૈયારી હોય તો SDK direct. Toolને appને જરૂરી control પ્રમાણે પસંદ કરો.

Summary

Key takeaways

  • FirebaseUI Auth complete, prebuilt sign-in flow છે, જેને appમાં drop-in કરી શકાય છે.
  • Offer કરવાના providersની list configure કરો, sign-in Intent launch કરો, અને FirebaseUI ready-made login screens બતાવે છે.
  • તે registration, login, provider flows અને errors handle કરીને result activityને પાછો આપે છે.
  • Success પછી user સામાન્ય રીતે FirebaseAuthમાં signed in હોય છે અને auth.currentUser set થાય છે.
  • લાભ: ઓછા codeમાં fast, best-practice login; trade-off: exact look અને flow પર control ઓછો.
  • Custom login UI અથવા unusual flow જોઈએ ત્યારે Firebase SDK direct વાપરો.
  • Memory hook: FirebaseUI એટલે drop-in login; providersની list આપો અને launch કરો, screens તે જાતે બનાવે છે.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Introduction to Firebase

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Introduction to FirebaseUI Auth authentication · Advance Mobile Application Development - II (Major-15-02) · Gri-Learn