FB4D

Open Source Library for connecting Firebase by Delphi VCL/FMX

View project on GitHub

FB4D – The OpenSource Cross-Platform Library for Firebase

The Google Firebase Cloud Database is used in many mobile and web applications worldwide and there are well-documented libraries for many languages and platforms. For Delphi, the cross-platform library FB4D supports the Firestore Database, the Firebase Realtime Database, the Firebase Storage (for file storage), Firebase Functions (for calling server functions), and Vision ML. For authentication, FB4D currently supports email/password authentication, login by using a Google Account, and anonymous login.

The library builds on the Firebase REST-API and provides all functionality with synchronous and asynchronous methods for use within GUI applications, services, and background threads. Both frameworks VCL and Firemonkey are supported. The library is a pure source code library that relies on class interfaces. For clean and short application code, it supports fluent interface design.

Wiki

This project offers a wiki. Seven cross-platform example applications based on Firemonkey and three VCL sample applications and a Getting-Started on the wiki will help you to start working with the library. For more detailed questions, the interface reference will provide the answers you need.

You can find more learning videos on the following YouTube channel.

Major Change log

This log informs about interface changes and significant library enhancements that need the attention of users of this library.

  • March 2025: Add authentication by using Google Accounts. The DemoFB4D App demonstrates the functionality after setting up the Firebase Project for using this auth provider. Check the wiki for details.
  • October 2024: GeminiAI service added, a new tab in the DemoFB4D App demonstrates the functionality;
  • August 2024: Refactoring and many improvements in DemoFB4D App;
  • June 2024: Adding TOTDMapperOptions to control the behavior of the Object-To-Doc mapper. The simple FMX demo application FSObj2Doc demonstrates the Object-To-Document Mapper and has been added to the FB4D Samples project group. Add IFirestoreWriteTransaction.TransformDoc for SetServerTime, Increment, Maximum, Minimum;
  • February 2024: Migrate to Delphi Athene;
  • December 2023: The Object to Document Mapper lets you quickly sync your Pascal objects to the Firestore database by deriving your own class from TFirestoreDocument and adding member variables. All member variables are automatically written to the document and read from the document. The sample application FSObj2Doc demonstrates the functionality;
  • October 2023: Firestore database write transaction supports deleting documents too. The Auth_SelfReg_VCL demo application explains all options of the self-registration workflow;
  • June 2023: Firestore database supports write transactions;
  • October 2022: Interface for ML Vision service added;
  • April 2021: Revised RT DB Listener;
  • March 2021: New optional cache to accelerate the repeated access to storage objects. Additional IFirebaseStorage.GetAndDownload method to simplify the download from the storage. See more details
    New option in FB4D.SelfRegistrationFra framework to support entering display name and uploading profile image when registering a new user. See more details
    Real-Time database creation has changed within the Firebase Console. The Firebase ID is no longer sufficient to access newly created RT DBs. A Firebase URL is now required, which can also include the server location. See more details.
    A new listener detects changes within the Firestore Database without pooling. See more details.

Prerequisites

The sample projects are developed and prepared for Delphi 12.3 Athens.

🔺 This library requires at least Delphi 11.0 Alexandria🔺.

Hint: Support from Delphi 10 Seattle to Delphi 10.2 Tokyo has been discontinued since the introduction of the Firestore Listener in March 2021. Delphi 10.3 Update 1 and earlier versions are no longer supported because of an issue in the RTL. Delphi 10.4 Support is removed since FB4D V1.8.0 because of missing TBase64StringEncoding.

Delphi is a registered trademark of Embarcadero Technologies, Inc.

Supported Platforms

FB4D is developed in pure object Pascal and can be used with Firemonkey on all supported platforms. The library and its sample projects are currently tested with Win64/Win32, Mac64/32, and Linux64 by using FMXLinux, iOS64, and Android. (Hint to mobile platforms: The TokenJWT to perform the token verification requires the installation of the OpenSSL libraries). For more information about using OpenSSL see the installation of OpenSSL

Hints for Windows

In the DemoFB4D app, the Edge web browser is used to display Markdown as HTML and PDF. To do this, it is necessary to install the WebView2 SDK or at least copy the WebView2Loader.dll into your executable directory. Read more about WebView2 and TWebBrowser on Embarcadero’s Wiki. This upgrade is only necessary under Win32 and Win64.

Limitation on Android for VisionML

AnnotateFile is limited to PDF only, as GIF support does not work due to RSP-17682, and the TIF image format is not yet supported.

Limitation on iOS for VisionML

AnnotateFile is limited to PDF only, as the GIF and TOF image format is not yet supported by FMX.Graphics. You cannot convert a TBitmap to one of the image formats required by VisionML with the standard library.

Limitation on Linux64

There are no restrictions when using Delphi 11 Alexandria or higher.

Submodules

Important note about path changes: Since the introduction of Gemini AI (V1.6.5.631) the folder JOSE has been moved to submodules/delphi-jose-jwt because the additional submodule Delphi-Markup was added. After GIT pull, please update both submodules with the Git Bash command git submodule update --remote --merge or use your favorite Git tool for this update.

Delphi-JOSE-JWT

For authorization token verification and token content extraction this library uses the Delphi JOSE JWT library. Thank you, Paolo Rossi for your great library!

github.com/paolo-rossi/delphi-jose-jwt

Delphi-Markdown

For converting markdown formatted text into HTML this library uses the Delphi Markdown Library. Thank you, Grahame Grieve for this great library!

github.com/grahamegrieve/delphi-markdown

Sponsoring FB4D

I recommend that anyone using this open-source library in a commercial project should consider sponsoring it. This is the only way this valuable library can be maintained and further developed. Read more about the benefits of sponsoring here.

Christoph Schneider, Schneider Infosystems AG, Switzerland www.schneider-infosys.ch

Logo FB4D