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
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
Sign in with a Google account.
- Parameters:
- (No parameters)
SignUpWithEmail
Create an account using email and password.
- Parameters:
password
(text): The user's password.verify
(boolean): A flag indicating whether the email should be verified.
SignInWithEmail
Sign in to your account using your email and password.
- Parameters:
password
(text): The user's password.
SendVerificationEmail
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:
SignInWithPhone
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
Send the SMS with the verification code again.
- Parameters:
- (No parameters)
GetUserData
Get registered user details.
- Parameters:
- (No parameters)
IsSignedIn
Check if the user is signed in.
Parameters:
- (No parameters)
Return Type:
- boolean
SignOut
Sign out the user.
- Parameters:
- (No parameters)
ConnectionTags
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
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
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
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
Get data from the given bucket.
- Parameters:
bucket
(text): The path to the bucket to retrieve data from.
GetDataWithKeyValue
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
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
Will trigger when an error occurs.
- Parameters:
error
(text): A message describing the error.
SignedIn
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
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
Will be triggered when an SMS with a verification code is sent.
- Parameters:
- (No parameters)
SignedOut
Will be triggered when the user signs out.
- Parameters:
- (No parameters)
Saved
Will trigger when data is written using any method.
- Parameters:
- (No parameters)
BucketChanged
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
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
Will trigger when data is retrieved via any method.
- Parameters:
value
(any): The retrieved data.
Removed
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.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.
- pl.patryk_f.firebaseplus.aix (2.0 MB)
AIA
Sample project.