-
-
Notifications
You must be signed in to change notification settings - Fork 54
FB4D Interface Reference
This document describes all FB4D class interfaces locatable in the unit FB4D.Interfaces. To simplify the interface description the synchronous method call will be described only. The asynchronous method requires the same parameters together with two call back methods for success and failure situation. Keep in mind that for asynchronous calls the caller class must be alive as long the call is ongoing.
The interface IFirebaseConfiguration provides an easy way to access all other interfaces of FB4D. It contains a class factory to store the instances of the interface to authentication, both databases, the storage, the Firebase functions, and the VisionML.
IFirebaseConfiguration = interface(IInterface)
function ProjectID: string;
function Auth: IFirebaseAuthentication;
function RealTimeDB: IRealTimeDB;
function Database(const DatabaseID: string = cDefaultDatabaseID): IFirestoreDatabase;
function Storage: IFirebaseStorage;
function Functions: IFirebaseFunctions;
function VisionML: IVisionML;
procedure SetBucket(const Bucket: string);
end;
Because all instances are returned as interfaces, Auto Reference Counting (ARC) is used, where you do not have to release any instances yourself.
There are two ways to create an instance of the class TFirebaseConfiguration: Either you pass all credentials of the firebase project as parameters or you let parse the google-services JSON file to retrieve these parameters at application run time.
constructor TFirebaseConfiguration.Create(const ApiKey, ProjectID: string;
const Bucket: string = ''; const FirebaseURL: string = '';
const ServerRegion: string = cRegionUSCent1); overload;
If the bucket for the storage is not yet known when the config class is created, for example, because this information is still being requested by the user, the bucket can still be provided with the following method before the first access to the storage takes place.
procedure SetBucket(const Bucket: string);
If the Firebase URL is not yet known when the config class is created, this URL can still be provided with the following method before the first access to the RealTimeDB takes place.
procedure SetFirebaseURL(const FirebaseURL: string);
Before the first use of functions, you can define the region of the Firebase Function Server in case you do not use servers in Iowa.
procedure SetServerRegion(const ServerRegion: string);
The following server locations are predefined in constants:
const
cRegionUSCent1 = 'us-central1'; // Iowa
cRegionUSEast1 = 'us-east1'; // South Carolina
cRegionUSEast4 = 'us-east4'; // Nothern Virginia
cRegionUSWest2 = 'us-west2'; // Los Angeles
cRegionUSWest3 = 'us-west3'; // Salt Lake City
cRegionUSWest4 = 'us-west4'; // Las Vegas
cRegionUSNoEa1 = 'northamerica-northeast1'; // Montreal
cRegionUSSoEa1 = 'southamerica-east1'; // Sao Paulo
cRegionEUWest1 = 'europe-west1'; // Belgium
cRegionEUWest2 = 'europe-west2'; // London
cRegionEUWest3 = 'europe-west3'; // Frankfurt
cRegionEUWest6 = 'europe-west6'; // Zürich
cRegionEUCent2 = 'europe-central2'; // Warsaw
cRegionAUSoEa1 = 'australia-southeast1'; // Sydney
cRegionASEast1 = 'asia-east1'; // Taiwan
cRegionASEast2 = 'asia-east2'; // Hong Kong
cRegionASNoEa1 = 'asia-northeast1'; // Tokyo
cRegionASNoEa2 = 'asia-northeast2'; // Osaka
cRegionASSout1 = 'asia-south1'; // Mumbai
cRegionASSoEa1 = 'asia-southeast1'; // Singapore
cRegionASSoEa2 = 'asia-southeast2'; // Jakarta
cRegionASSoEa3 = 'asia-southeast3'; // Seoul
The first constructor requires all secrets of the Firebase project as ApiKey and ProjectID and when using the Storage and the storage Bucket and accessing the Firebase RT-DB the FirebaseURL as parameters.
constructor Create(const GoogleServicesFile: string); overload;
The second constructor parses the google-services.json file that shall be loaded from the Firebase Console after adding an App to the project settings.
If you need to configure another server region than the default one (us-central1) for Firebase Function call SetServerRegion
as this information is unfortunately not in the service file.
The following class function returns the library version number.
class function TFirebaseConfiguration.GetLibVersionInfo: string;
The following class function returns the library license information.
class function TFirebaseConfiguration.GetLibLicenseInfo: string;
The unit FB4D.Helpers offers important helper functions in different classes and class helpers.
Class Helper TQueryParamsHelper
In most applications, you will not call any other Firebase services until you have received an authentication token using the Firebase Authentication Service. For a quick and dirty application (e.g. RTDB_SimpleReadWrite of the FB4D Sample Projects), you can also use a service without such an authentication token. In this case, however, you must disable all access rules for Firebase.
Interface IFirebaseAuthentication
Another good source of inspiration is the GUI Pattern to integrate a self-registration workflow for e-mail and password authorization.
The Firebase Real-Time Database is a NoSQL cloud database for store and synchronize data between multiple client applications. The data is stored as a large JSON tree. Applications can register an event handler to monitor all changes in and under a JSON node.
The Firestore Database is newer than the Realtime Database and better scalable and more flexible. It allows queries comparable to SQL databases. The Firestore offers the possibility to listen to changes in documents and collections without polling the database.
The Firebase Storage stores any kind of files in a directory structure. For more information about the Firebase Storage read first the Google Cloud Storage Documentation.
The Firebase Cloud Functions lets you automatically run backend-code called from your application.
The Vision ML offers functions based on machine learning for image recognition and interpretation.
This interface provides machine-generated text capabilities based on the Gemini AI API.
The results of the AI are returned in the IGeminiAIResponse interface.
For more complex questions to the AI with attached media files or model parameters the IGeminiAIRequest interface is used.
The following two interfaces are normally used internally in the library only.
Have you discovered an error? Or is something unclear? Please let us know in the discussion forum.
Schneider Infosystems Ltd. CH-6340 Baar, Switzerland, www.schneider-infosys.ch
Introduction into FB4D
Getting Started
Fundamental Principles
Project Settings
GUI Pattern Self-Registration
RT-DB Sample Applications
Firestore Chat Sample Applications
PhotoBox demonstrates Firestore, Storage, VisionML
Interface Reference
Configuration and Class Factory
Helper Classes
Authentication