Firebase - (Cloud)Firestore

DonManfred

Expert
Licensed User
FirebaseFirestore

Author:
DonManfred
Version: 0.58
  • Blob
    • Functions:
      • Initialize (blobcontent As Byte())
      • IsInitialized As Boolean
      • toString As String
    • Properties:
      • Bytes As Byte() [read only]
  • Car
    • Functions:
      • Initialize (name As String, Category As String, location As com.google.firebase.firestore.GeoPoint, photoUrl As String, DriverRef As com.google.firebase.firestore.DocumentReference)
    • Properties:
      • Category As String
      • Driver As com.google.firebase.firestore.DocumentReference
      • Id As String
      • Location As com.google.firebase.firestore.GeoPoint
      • Name As String
      • NumberPlate As String
      • PhotoUrl As String
  • CollectionReference
    • Events:
      • onValue (value As DocumentReference)
      • Snapshot (snap As QuerySnapshot)
    • Functions:
      • add (obj As Map)
      • add2 (obj As Object)
      • addSnapshotListener
      • document As DocumentReference
      • endAt (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • endAt2 (snap As Object) As Query
      • endBefore (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • endBefore2 (snap As Object) As Query
      • Initialize (EventName As String, collection As String, tag As Object)
      • IsInitialized As Boolean
      • limit (limit As Long) As Query
      • orderBy (path As String) As Query
      • orderBy2 (path As com.google.firebase.firestore.FieldPath) As Query
      • orderBy3 (path As String, direction As String) As Query
      • orderBy4 (path As com.google.firebase.firestore.FieldPath, direction As String) As Query
      • setEventname (EventName As String, Tag As Object) As CollectionReference
      • startAfter (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • startAfter2 (snap As Object) As Query
      • startAt (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • startAt2 (snap As Object) As Query
      • whereEqualTo (path As String, value As Object) As Query
      • whereEqualTo2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
      • whereEqualToString (path As String, value As String) As Query
      • whereGreaterThan (path As String, value As Object) As Query
      • whereGreaterThan2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
      • whereLessThan (path As String, value As Object) As Query
      • whereLessThan2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
      • whereLessThanOrEqualTo (path As String, value As Object) As Query
      • whereLessThanOrEqualTo2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
    • Properties:
      • BA As BA [read only]
      • EventName As String [read only]
      • Id As String [read only]
      • Parent As DocumentReference [read only]
      • Path As String [read only]
      • Tag As Object
  • DocumentChange
    • Functions:
      • Initialize (dev As com.google.firebase.firestore.DocumentChange)
      • IsInitialized As Boolean
    • Properties:
      • DocType As com.google.firebase.firestore.DocumentChange.Type [read only]
      • DocType2 As String [read only]
      • Id As com.google.firebase.firestore.DocumentSnapshot [read only]
      • NewIndex As Int [read only]
      • OldIndex As Int [read only]
  • DocumentReference
    • Events:
      • onEvent (snap As Object, error As Object)
      • onValueSet (value As Object)
    • Functions:
      • addSnapshotListener As com.google.firebase.firestore.ListenerRegistration
      • Getvalue
      • Initialize (EventName As String, docref As com.google.firebase.firestore.DocumentReference)
      • IsInitialized As Boolean
      • set (value As Object, tag As Object)
      • setEventname (EventName As String, Tag As Object) As DocumentReference
    • Properties:
      • EventName As String [read only]
      • Id As String [read only]
      • Parent As com.google.firebase.firestore.CollectionReference [read only]
      • Path As String [read only]
      • Tag As Object
  • DocumentSnapshot
    • Functions:
      • contains (arg0 As String) As Boolean
      • exists As Boolean
      • get (arg0 As String) As Object
      • getBlob (path As String) As com.google.firebase.firestore.Blob
      • getBoolean (arg0 As String) As Boolean
      • getDate (path As String) As Long
      • getDocumentReference (path As String) As com.google.firebase.firestore.DocumentReference
      • getDouble (path As String) As Double
      • getGeoPoint (path As String) As com.google.firebase.firestore.GeoPoint
      • getLong (path As String) As Long
      • getString (path As String) As String
      • Initialize (EventName As String, snap As com.google.firebase.firestore.DocumentSnapshot)
      • IsInitialized As Boolean
      • setEventname (EventName As String, Tag As Object) As DocumentSnapshot
    • Properties:
      • Data As MyMap [read only]
      • EventName As String [read only]
      • Id As String [read only]
      • Metadata As com.google.firebase.firestore.SnapshotMetadata [read only]
      • Reference As com.google.firebase.firestore.DocumentReference [read only]
      • Tag As Object
  • Driver
    • Functions:
      • Initialize (id As String, username As String, name As String, Category As String, location As com.google.firebase.firestore.GeoPoint, photoUrl As String, City As String)
    • Properties:
      • Category As String
      • City As String
      • Id As String
      • Location As com.google.firebase.firestore.GeoPoint
      • PhotoUrl As String
      • RealName As String
      • UserName As String
  • Firestore
    • Functions:
      • batch As com.google.firebase.firestore.WriteBatch
      • collection (collection As String, tag As Object) As CollectionReference
      • collection2 (collection As String) As CollectionReference
      • document (document As String) As DocumentReference
      • Initialize (EventName As String, logging As Boolean)
    • Properties:
      • FirestoreSettings As com.google.firebase.firestore.FirebaseFirestoreSettings [read only]
      • isInitialized As Boolean [read only]
  • GeoPoint
    • Functions:
      • Initialize (lat As Double, lon As Double)
      • IsInitialized As Boolean
    • Properties:
      • Latitude As Double [read only]
      • Longitude As Double [read only]
  • Query
    • Events:
      • Snapshot (sign As Object)
    • Functions:
      • endAt (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • endAt2 (snap As Object) As Query
      • endBefore (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • endBefore2 (snap As Object) As Query
      • fetch (EventName As String)
      • Initialize (EventName As String, query As com.google.firebase.firestore.Query)
      • IsInitialized As Boolean
      • limit (limit As Long) As Query
      • orderBy (path As String) As Query
      • orderBy2 (path As com.google.firebase.firestore.FieldPath) As Query
      • orderBy3 (path As String, direction As String) As Query
      • orderBy4 (path As com.google.firebase.firestore.FieldPath, direction As String) As Query
      • startAfter (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • startAfter2 (snap As Object) As Query
      • startAt (snap As com.google.firebase.firestore.DocumentSnapshot) As Query
      • startAt2 (snap As Object) As Query
      • whereEqualTo (path As String, value As Object) As Query
      • whereEqualTo2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
      • whereEqualToString (path As String, value As String) As Query
      • whereGreaterThan (path As String, value As Object) As Query
      • whereGreaterThan2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
      • whereLessThan (path As String, value As Object) As Query
      • whereLessThan2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
      • whereLessThanOrEqualTo (path As String, value As Object) As Query
      • whereLessThanOrEqualTo2 (path As com.google.firebase.firestore.FieldPath, value As Object) As Query
  • QuerySnapshot
    • Functions:
      • Initialize (EventName As String, snap As com.google.firebase.firestore.QuerySnapshot)
      • IsInitialized As Boolean
      • setEventname (EventName As String, Tag As Object) As QuerySnapshot
    • Properties:
      • DocumentChanges As List [read only]
      • Documents As List [read only]
      • Empty As Boolean [read only]
      • EventName As String [read only]
      • Metadata As com.google.firebase.firestore.SnapshotMetadata [read only]
      • Query As com.google.firebase.firestore.Query [read only]
      • Size As Int [read only]
      • Tag As Object
  • SnapshotMetadata
    • Functions:
      • Initialize (dev As com.google.firebase.firestore.SnapshotMetadata)
      • IsInitialized As Boolean
    • Properties:
      • hasPendingWrites As Boolean [read only]
      • isFromCache As Boolean [read only]

Setup Firebase Firestore:
- You need to have firebaseAnalytics.1.12+ and firebaseNotification
- Follow the firebase Integration Tutorial.

- Add this dependencies to your main module (you´ll find the additional jars in the Download.
B4X:
#MultiDex: true
#AdditionalJar: com.google.firebase:firebase-common
#AdditionalJar: com.google.firebase:firebase-auth
#AdditionalJar: com.google.firebase:firebase-database
#AdditionalJar: com.google.firebase:firebase-core
#AdditionalJar: com.google.firebase:firebase-common
#AdditionalJar: com.google.firebase:firebase-firestore
#AdditionalJar: grpc-all-1.22.1.jar
#AdditionalJar: grpc-api-1.22.1.jar
#AdditionalJar: grpc-core-1.22.1.jar
#AdditionalJar: grpc-okhttp-1.22.1.jar
#AdditionalJar: grpc-android-1.22.1.aar
#AdditionalJar: grpc-context-1.22.1.jar
#AdditionalJar: grpc-stub-1.22.1.jar
#AdditionalJar: grpc-protobuf-lite-1.22.1.jar

#AdditionalJar: opencensus-api-0.23.0.jar
#AdditionalJar: opencensus-contrib-grpc-metrics-0.23.0.jar
#AdditionalJar: opencensus-contrib-http-util-0.23.0.jar
#AdditionalJar: perfmark-api-0.17.0.jar
#AdditionalJar: guava-27.1-android.jar
#ExcludeClasses: com.google.guava:guava-jdk5
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim fs As Firestore
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")

    fs.Initialize("Firestore",True)
    Dim driver As CollectionReference = fs.collection("Drivers","DriverCollection")
    If driver <> Null Then
        Log("Setting query to get driver DonManfred")
        driver.whereEqualTo("id","DonManfred").limit(1).fetch("DriverFetch")
        wait for DriverFetch_Snapshot(snap As QuerySnapshot)
        Log($"Driver_Snapshot(${snap.Size},${snap})"$)
        Dim meta As SnapshotMetadata = snap.Metadata
        Dim documents As List = snap.Documents
        'Log(documents)
        If documents.IsInitialized Then
            If documents.Size > 0 Then
                For i = 0 To documents.Size-1
                    Dim docsnap As DocumentSnapshot = documents.Get(i)
                    Log("Query4DonManfred DocumentNo: #"&i&": "&docsnap.Id)
                Next
            End If
        Else
            Log("Snapshot does not contain a list of Documents...")
        End If
    end if
end sub
Please create a new Thread in the questionsforum about every question/Issue you have.

Download here.
 
Last edited:
Top