B4A Library Firebase UI Auth - a new Dimension in Authentication

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Dec 23, 2017.

  1. DonManfred

    DonManfred Expert Licensed User

    This is a Wrap for the Firebase UI-bindings found at Github.

    It offers Authentification using
    - Google-Account (Tested)
    - email and password authentification (Tested)
    - Telephone-Authentification (Tested)
    - Twitter (Not tested as i do not have a Twitter-Dev Account)
    - Facebook (Not tested as i do not have a Facebookr-Dev Account)
    - Authentification using a Custom Token generated by the FirebaseAdmin SDK (B4J Library currently in Beta)

    For the last two (Twitter and Facebook) there must be made additional changes to the Manifest.

    - B4A 7.8+
    - Manifestchanges needed!
    - You app needs to be AppCompat enabled (must use AppCompat)

    - Prepare your app to use Firebase. https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/#content
    - Google Play Services Base - Snippet
    - Firebase Base - Snippet
    - Firebase Auth - Snippet
    - Additional Manifestentries for the firebase-UI bindings

    Add this line to your Manifest to define the needed Firebase UI Activities.

    CreateResourceFromFile(Macro, FirebaseUI.uibindings)
    - Mandatory additional Jars needed to the B4A Code

    #Extends: android.support.v7.app.AppCompatActivity
    #AdditionalJar: com.google.android.gms:play-services-auth
    #AdditionalJar: com.android.support.constraint:constraint-layout
    #AdditionalJar: com.android.support.constraint:constraint-layout-solver
    #AdditionalJar: com.google.firebase:firebase-auth
    #AdditionalJar: com.android.support:customtabs
    #AdditionalJar: android.arch.lifecycle:extensions
    #AdditionalJar: firebase-ui-auth.aar
    #AdditionalJar: firebase-ui-common.aar
    #AdditionalJar: firebase-ui-database.aar
    #AdditionalJar: firebase-ui-firestore.aar
    #AdditionalJar: firebase-ui-storage.aar
    #AdditionalRes: ..\res.FirebaseUI
    Basically you setup the allowed Auth methods with this Code:
    Dim ib As SignInIntentBuilder
    Dim intent As Intent
    intent = ib.setAllowNewEmailAccounts(True).setIsSmartLockEnabled2(False,True).setProviders(ib.Providerlist).setTosUrl("http://URLtoTOS").setPrivacyPolicyUrl("http://URLtoTOS").build
    It will result in a Auth-Selection

    WhatsApp Image 2017-12-23 at 08.39.48.jpeg

    Using email
    WhatsApp Image 2017-12-23 at 08.43.59.jpeg

    Using new email:
    WhatsApp Image 2017-12-23 at 08.45.26.jpeg


    Author: DonManfred (wrapper)
    Version: 0.21
    • FirebaseOptions
      • Functions:
        • Initialize (apiKey As String, appID As String, dbUrl As String, GcmsenderID As String, bucketID As String) As com.google.firebase.FirebaseOptions
    • FirebaseUI
      • Events:
        • IdTokenChanged (user As FirebaseUser)
        • SignedIn (user As FirebaseUser)
        • SignedOut()
        • TokenAvailable (user As FirebaseUser, success As Boolean, token As String)
        • UpdateEmail (success As Boolean, email As String)
        • UpdatePassword (success As Boolean, password As String)
        • UpdateProfile (success As Boolean, request As Object)
      • Functions:
        • AddIdTokenListener (listener As com.google.firebase.auth.FirebaseAuth.IdTokenListener)
        • AddListener (listener As com.google.firebase.auth.FirebaseAuth.AuthStateListener)
        • CreateIdTokenListener As com.google.firebase.auth.FirebaseAuth.IdTokenListener
        • CreateListener As com.google.firebase.auth.FirebaseAuth.AuthStateListener
        • createSignInIntentBuilder As com.firebase.ui.auth.AuthUI.SignInIntentBuilder
        • Initialize (EventName As String)
        • RemoveIdTokenListener (listener As com.google.firebase.auth.FirebaseAuth.IdTokenListener)
        • RemoveListener (listener As com.google.firebase.auth.FirebaseAuth.AuthStateListener)
        • SendSigninIntent (signin As android.content.Intent)
        • signInWithCustomToken (token As String)
        • signOut
        • updateEmail (newEmail As String)
        • updatePassword (newPassword As String)
      • Properties:
        • CurrentUser As FirebaseUser [read only]
    • FirebaseUser
      • Functions:
        • isAnonymous As Boolean
        • isEmailVerified As Boolean
        • IsInitialized As Boolean
      • Properties:
        • DisplayName As String [read only]
        • Email As String [read only]
        • PhotoUrl As String [read only]
        • Uid As String [read only]
    • SignInIntentBuilder
      • Functions:
        • addProvider (provider As com.firebase.ui.auth.AuthUI.IdpConfig)
        • build As android.content.Intent
        • clearProvider
        • Initialize (EventName As String, builder As com.firebase.ui.auth.AuthUI.SignInIntentBuilder)
        • IsInitialized As Boolean
        • setAllowNewEmailAccounts (enabled As Boolean) As SignInIntentBuilder
        • setAvailableProviders (providers As java.util.List) As SignInIntentBuilder
        • setIsSmartLockEnabled (enabled As Boolean) As SignInIntentBuilder
        • setIsSmartLockEnabled2 (enableCredentials As Boolean, enableHints As Boolean) As SignInIntentBuilder
        • setLogo (logo As Int) As SignInIntentBuilder
        • setPrivacyPolicyUrl (privacyPolicyUrl As String) As SignInIntentBuilder
        • setTheme (theme As Int) As SignInIntentBuilder
        • setTosUrl (tosUrl As String) As SignInIntentBuilder
      • Properties:
        • IdpEMAIL_PROVIDER As com.firebase.ui.auth.AuthUI.IdpConfig [read only]
        • IdpFACEBOOK_PROVIDER As com.firebase.ui.auth.AuthUI.IdpConfig [read only]
        • IdpGOOGLE_PROVIDER As com.firebase.ui.auth.AuthUI.IdpConfig [read only]
        • IdpPHONE_VERIFICATION_PROVIDER As com.firebase.ui.auth.AuthUI.IdpConfig [read only]
        • IdpTWITTER_PROVIDER As com.firebase.ui.auth.AuthUI.IdpConfig [read only]
        • Providerlist As java.util.List [read only]
    The Library is free to use. It is my Christmas Present to you!

    You can however donate for it if you want :)

    Merry Christmas

    Attached Files:

    Last edited: May 6, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    Nice work! Looks like a challenging library to create.
  3. Emme Developer

    Emme Developer Well-Known Member Licensed User

    I know it's not much, as much as I can at the moment, but would like to be a thank you for the work you do every day, with libraries, wrappers and user help. Thank you and merry Christmas
  4. yiankos1

    yiankos1 Active Member Licensed User

    Merry Christmas Don,
    Why i can't find attached lib?
    Claudio Oliveira likes this.
  5. DonManfred

    DonManfred Expert Licensed User

    I dont understand the question.
    I tried to download all threee files from post #1 and it works fine here.

    What exactly is the issue?
  6. yiankos1

    yiankos1 Active Member Licensed User

    Thank you for quick reply. I downloaded all three zips. At the second zip(with aar) there is no lib (.jar & xml file) in order to copy at libs folder. I just copied only .aar files but at running throws that i am missing a library.
  7. DonManfred

    DonManfred Expert Licensed User

    It throws what? You did not post any error log with the crash. How do you expect i could help?

    EDIT: OHHHHHH. I think i see! Wait a moment
    Claudio Oliveira likes this.
  8. DonManfred

    DonManfred Expert Licensed User

    Added the missing Library (SORRY!) to Post #1
    Claudio Oliveira and yiankos1 like this.
  9. yiankos1

    yiankos1 Active Member Licensed User

    Thank you very much for that quick assistance. Sorry for any inconvenience.
    Claudio Oliveira likes this.
  10. DonManfred

    DonManfred Expert Licensed User

    at the end i should thank as you pointed out that the Library itself was missing :)
    Claudio Oliveira and yiankos1 like this.
  11. yiankos1

    yiankos1 Active Member Licensed User

    So, even 17 likes at first post, i am the first one testing it! :p
    DonManfred and Claudio Oliveira like this.
  12. yiankos1

    yiankos1 Active Member Licensed User

    Library working like a charm!!!
    I have already done the necessary work for facebook login configuration with direction of your previous firebase facebook login

    If i attach this aar file from Facebook SDK:
    #AdditionalJar: facebook-core.aar
    i get this error:
    ** Activity (main) Resume **
    Service (newinst2) Start **
    ---- AppUpdating.newinst2: service_started
    Service (newinst2) Start **
    ---- AppUpdating.newinst2: service_started
    Activity (main) Pause, UserClosed = false **
    java.lang.NoClassDefFoundError: com.firebase.ui.auth.provider.FacebookProvider
        at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.populateIdpList(AuthMethodPickerActivity.java:
        at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onCreate(AuthMethodPickerActivity.java:
        at android.app.Activity.performCreate(
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
        at android.app.ActivityThread.access$
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
        at android.os.Handler.dispatchMessage(Handler.java:
        at android.os.Looper.loop(Looper.java:
        at android.app.ActivityThread.main(ActivityThread.java:
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    Last edited: Dec 28, 2017
    Claudio Oliveira likes this.
  13. Claudio Oliveira

    Claudio Oliveira Active Member Licensed User

    Yeah, that's right! :D
    Although I haven't tried it yet, I really liked what the lib is expected to do.
    I'l try to test it today...
  14. DonManfred

    DonManfred Expert Licensed User

    Please create a new thread in the Questions forum for your question.

    Post the code you are using to initialize the providerlist....
  15. DonManfred

    DonManfred Expert Licensed User

    Updated to V0.11

    - Authentification using a Custom Token generated by the FirebaseAdmin SDK (B4J Library currently in Beta)
  16. syderbit

    syderbit Member Licensed User

    These include sendEmailVerification ?? :rolleyes:
  17. DonManfred

    DonManfred Expert Licensed User

    What do you mean exactly???
    What is the question?
  18. syderbit

    syderbit Member Licensed User

    sorry my bad english
    when i use this library, how to request email verification to firebase auth??

    Attached Files:

  19. DonManfred

    DonManfred Expert Licensed User

    there is no method for it in the UI Bindings. See github.

    If you need a verification then you need to build this solution by yourself
  20. yiankos1

    yiankos1 Active Member Licensed User

    If i want to edit layout of this intent, which file should i edit?
    Moreover, setLogo (logo As Int) As SignInIntentBuilder and setTheme (theme As Int) As SignInIntentBuilder what will be integers?
    Thank you for your time.

    I figured out how to set logo with this code:
    Dim r As Reflector
    Dim package As String
    Dim id As Int
        package = r.GetStaticField(
    id = r.GetStaticField(package & ".R$drawable""icon")
    icon is the default .png inside this folder ..\FirebaseUI\Objects\res\drawable
    Last edited: Feb 22, 2018
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice