FirebasePlus - Authenticate and manage your realtime database

Overview

FirebasePlus is an extension for managing Authentication and the Realtime Database in Google Firebase. This extension does not work with Companion. It can only be used in compiled apps.
The minimum Android API level for this extension is 16 (Android 4.1).
Extension compiled with Rush. Thanks @shreyash .

Any suggestions for new blocks and modifications are welcome. If you encounter any errors, please report them in this thread.

Table of Contents

Initialization

Summary

To use the FirebasePlus extension, you need to initiate a connection to the database. You'll need to provide the projectId, apiKey, databaseUrl, and oAuthId.

Initiate

component_method (5)

Initiate a connection to the database.

  • Parameters:
    • projectId (text): The Firebase project ID ("project_id" from google-services.json).
    • apiKey (text): The API key for your Firebase project ("current_key" from google-services.json).
    • databaseUrl (text): The URL of your Firebase Realtime Database ("firebase_url" from google-services.json).
    • oAuthId (text): The OAuth ID for your Firebase project. Only required if signed in with a Google account ("client_id"{"client_type" : 3} from google-services.json).

Authentication

Summary

FirebasePlus provides various methods for user authentication.

SignInWithGoogle

component_method (6)

Sign in with a Google account.

  • Parameters:
    • (No parameters)

SignUpWithEmail

component_method (7)

Create an account using email and password.

  • Parameters:
    • email (text): The user's email address.
    • password (text): The user's password.
    • verify (boolean): A flag indicating whether the email should be verified.

SignInWithEmail

component_method (8)

Sign in to your account using your email and password.

  • Parameters:
    • email (text): The user's email address.
    • password (text): The user's password.

SendVerificationEmail

component_method (28)

Sends a verification link to the user's email.

  • Parameters:
    • (No parameters)

SendPasswordResetEmail

Send an email with a link to change the user's password.

  • Parameters:
    • email (text): The user's email address.

SignInWithPhone

component_method (11)

Sign in with the user's phone number.

  • Parameters:
    • phoneNumber (text): The user's phone number.

VerifyPhoneNumberWithCode

Verify the user's phone number with the code received via SMS.

  • Parameters:
    • code (text): The verification code received via SMS.

ResendVerificationSms

component_method (13)

Send the SMS with the verification code again.

  • Parameters:
    • (No parameters)

GetUserData

component_method (14)

Get registered user details.

  • Parameters:
    • (No parameters)

IsSignedIn

component_method (15)

Check if the user is signed in.

  • Parameters:

    • (No parameters)
  • Return Type:

    • boolean

SignOut

component_method (16)

Sign out the user.

  • Parameters:
    • (No parameters)

ConnectionTags

component_method (17)

Adds the user's connection tags to the given bucket ("connected": false, "timeStamp": 1698834723731).

  • Parameters:
    • bucket (text): The name of the bucket.

Realtime Database

Summary

FirebasePlus allows you to interact with the Realtime Database.

AddData

component_method (18)

Adds data in JSON format in the given bucket, to a randomly generated key.

  • Parameters:
    • bucket (text): The path to the bucket.
    • json (text): The JSON data to add.

SetData

component_method (19)

Sets the data in JSON format in the provided bucket, removing anything that is not in the data.

  • Parameters:
    • bucket (text): The path to the bucket.
    • json (text): The JSON data to set.

UpdateData

component_method (20)

Updates the JSON data in the provided bucket without changing anything that is not in the data.

  • Parameters:
    • bucket (text): The path to the bucket.
    • json (text): The JSON data to update.

GetData

component_method (21)

Get data from the given bucket.

  • Parameters:
    • bucket (text): The path to the bucket to retrieve data from.

GetDataWithKeyValue

component_method (22)

Get data from the given bucket that contains the given key with the given value.

  • Parameters:
    • bucket (text): The path to the bucket to retrieve data from.
    • key (text): The key to search for in the data.
    • value (any): The value to match for the key.

AddBucketChangeListener

Add a listener for the bucket, when changing data, all data from a given bucket will be downloaded.

  • Parameters:
    • bucket (text): The path to the bucket to add the listener to.

RemoveBucketChangeListener

Removes a listener in the specified bucket that was added using AddBucketChangeListener.

  • Parameters:
    • bucket (text): The path to the bucket to remove the listener from.

AddChildChangeListener

Add a listener for the bucket, when changing data, only the data that has been changed will be downloaded.

  • Parameters:
    • bucket (text): The path to the bucket to add the listener to.

RemoveChildChangeListener

Removes a listener in the specified bucket that was added using AddChildChangeListener.

  • Parameters:
    • bucket (text): The path to the bucket to remove the listener from.

RemoveData

component_method (27)

Deletes data from the given bucket.

  • Parameters:
    • bucket (text): The path to the bucket to remove data from.

Events

Summary

FirebasePlus triggers various events that you can listen to.

OnError

component_event (5)

Will trigger when an error occurs.

  • Parameters:
    • error (text): A message describing the error.

SignedIn

component_event (6)

Will be triggered when the user signs in or signs up.

  • Parameters:
    • userId (text): The user's unique ID.
    • providerId (text): The provider used for signing in.
    • verified (boolean): A flag indicating whether the user's email is verified.

EmailSent

component_event (7)

Will be triggered This text will be hiddenwhen a verification or password reset email is sent.

  • Parameters:
    • type (text): The type of email sent (verification or password reset).

VerificationSmsSent

component_event (8)

Will be triggered when an SMS with a verification code is sent.

  • Parameters:
    • (No parameters)

SignedOut

component_event (9)

Will be triggered when the user signs out.

  • Parameters:
    • (No parameters)

Saved

component_event (10)

Will trigger when data is written using any method.

  • Parameters:
    • (No parameters)

BucketChanged

component_event (11)

Will trigger when data observed via AddBucketChangeListener is changed.

  • Parameters:
    • key (text): The key of the data that changed.
    • value (any): The new value of the data.
    • bucket (text): The name of the bucket where the change occurred.

ChildChanged

component_event (12)

Will trigger when data observed via AddChildChangeListener is changed.

  • Parameters:
    • key (text): The key of the data that changed.
    • value (any): The new value of the data.
    • bucket (text): The name of the bucket where the change occurred.

GotData

component_event (13)

Will trigger when data is retrieved via any method.

  • Parameters:
    • value (any): The retrieved data.

Removed

component_event (14)

Will trigger when data is successfully removed using the RemoveData method.

  • Parameters:
    • (No parameters)

GotUserData

Will be triggered when the signed-in user's data is received.

  • Parameters:
    • userId (text): The user's unique ID.
    • email (text): The user's email address.
    • name (text): The user's name.
    • photo (text): The URL of the user's photo.
    • phoneNumber (text): The user's phone number.
    • verified (boolean): A flag indicating whether the user's email is verified.

Download

Version 1.0.0, date 05/11/2023.

AIX

Extension file.

AIA

Sample project.

3 Likes

Thanks for making this extension,

Especially providing it free for all users.

1 Like

I hope this helps someone. If anyone is missing any methods, please write and I will try to add them.

Firebase Storage: Upload,Download,Delete,List
Firestore

1 Like

Do you mean file storage support? Storage?

Yes I do :wink:

and for Firestore, well that is a whole new world that no-one seems to go near :wink:

Cloud Firestore?

Firebase Cloud Firestore

1 Like

I think I can add support for this database. I just need to read the documentation on how to use this database.

I tried only Phone Number Sign in as of now, it shows this error.

You didn't show your blocks. Sample project continues to build. You probably didn't initialize the extension using the Initiate block.

Made mobile number empty only to show you the blocks

Are you testing in APK?

yes,
Do i need to upload google-services.json to assets

No. I tested it and it worked, maybe I messed something up when cleaning the code or the build optimization messed something up. I'll be back here in some time.

Yes, Gmail,Email Authentication also have some issues,

I too think that something messed up as blocks works but not correct

Your IDs, although not fully visible, seem strange. Example identifiers should look like this:

projectId: free-messenger-da78f
apiKey: AIzaSyCUeXrBuskFo5lez3HNUwCMX0AloNYVS-g
databaseUrl: https://free-messenger-da78f-default-rtdb.firebaseio.com/
oAuthId: 424506119191-jo225krnmkl17vb4gmv9a2r3pt021joq.apps.googleusercontent.com

Also, for the phone number method to work, you must add the correct package name of your app and SHA certificate fingerprints in the firebase project. You also need to add appropriate authorization methods in the firebase project.

I tested the extension on android9 and it works fine. I'll test it on Android 10 soon. Unfortunately, I don't have a newer version of Android to test.

i can’t DM you,

All above done correctly.

This is different what i put, let me know where to get the ID

If you added the appropriate authorization methods in firebase, you should have this ID in google-services.json

Yes it EXITS while calling Any Sign-in methods,

I think you need to update the extension