B4A Class [B4X] FirebaseRealtimeDatabase

Hi,

I created a module that makes it easy to communicate with a Firebase RealtimeDatabase using their REST API.

The Module is attached to this post and only needs HTTPUtils2(iOS) to work, it should also work in B4A and B4J without a problem.

Example Code:

B4X:
Dim DB As FirebaseRealtimeDatabase
DB.Initialize("DB",Me,"https://[YOUR_PROJECT_ID].firebaseio.com/")
DB.ReadData("news/today","","news")
Wait For DB_DataBaseCommunicationComplete(ResponseData As Map, RequestTag As String)
If ResponseData.IsInitialized Then
   'Do your stuff
Else
   Msgbox("Something went wrong!","Oops...")
End If

Please Note: This is, by far, not best practice because it ignores a lot of features and advantages of the realtime database but for simple and small projects that just need a basic back-end it is usable and it works.
 

Attachments

  • FirebaseRealtimeDatabase.bas
    5.2 KB · Views: 385

DonManfred

Expert
Licensed User

erdi

Member
Licensed User
Hi,

I created a module that makes it easy to communicate with a Firebase RealtimeDatabase using their REST API.

The Module is attached to this post and only needs HTTPUtils2(iOS) to work, it should also work in B4A and B4J without a problem.

Example Code:

B4X:
Dim DB As FirebaseRealtimeDatabase
DB.Initialize("DB",Me,"https://[YOUR_PROJECT_ID].firebaseio.com/")
DB.ReadData("news/today","","news")
Wait For DB_DataBaseCommunicationComplete(ResponseData As Map, RequestTag As String)
If ResponseData.IsInitialized Then
   'Do your stuff
Else
   Msgbox("Something went wrong!","Oops...")
End If

Please Note: This is, by far, not best practice because it ignores a lot of features and advantages of the realtime database but for simple and small projects that just need a basic back-end it is usable and it works.
Hello,

I'm having trouble writing to my FireBase with DB.WriteData("","","Test","Vrij")
The message I'm getting is : "error" : "Invalid data; couldn't parse JSON object, array, or value."

I can do a DB.ReadData("","","Vrij") and DB.Deletedata succesfully.

Anny help would be appreciated... ;-)
 
Top