Getting started with TMS FNC Cloud Google Firebase
Prerequisites
- TMS FNC Core installed and the runtime package added to the project.
- TMS FNC Cloud Pack installed.
- A Google Firebase project with a Realtime Database, and an OAuth 2.0 client (client ID and secret) created in the Google Cloud console.
Add the component
- Drop
TTMSFNCCloudGoogleFireBaseObjectDatabaseonto a form or create it in code. - Set the OAuth credentials, the
DatabaseName, and theTableName. - Define a model class that descends from
TTMSFNCCloudGoogleFireBaseObject, register it withRegisterClass, then persist tokens and callConnect.
The minimal connect sequence — credentials, database/table target, token
persistence, and an OnConnected handler that reads the stored objects:
procedure TForm1.SetupFireBase;
begin
FDatabase := TTMSFNCCloudGoogleFireBaseObjectDatabase.Create(Self);
// OAuth 2.0 client credentials from the Google Cloud console.
FDatabase.Authentication.ClientID := '<your-client-id>.apps.googleusercontent.com';
FDatabase.Authentication.Secret := '<your-client-secret>';
FDatabase.Authentication.CallBackURL := 'http://127.0.0.1:8000';
// Target Realtime Database and the node (table) objects are stored under.
FDatabase.DatabaseName := '<your-firebase-database>';
FDatabase.TableName := 'Contacts';
// Persist tokens so the consent screen only appears on first run.
FDatabase.PersistTokens.Location := plIniFile;
FDatabase.PersistTokens.Key := TTMSFNCUtils.AddBackslash(TTMSFNCUtils.GetDocumentsPath)
+ FDatabase.ClassName + '.ini';
FDatabase.LoadTokens;
FDatabase.OnConnected := DatabaseConnected;
FDatabase.Connect; // opens the browser for consent on first run, then fires OnConnected
end;
procedure TForm1.DatabaseConnected(Sender: TObject);
begin
FDatabase.SaveTokens;
// Safe to read or write objects now.
FDatabase.ReadList(FObjects);
end;
void __fastcall TForm1::SetupFireBase()
{
FDatabase = new TTMSFNCCloudGoogleFireBaseObjectDatabase(this);
// OAuth 2.0 client credentials from the Google Cloud console.
FDatabase->Authentication->ClientID = "<your-client-id>.apps.googleusercontent.com";
FDatabase->Authentication->Secret = "<your-client-secret>";
FDatabase->Authentication->CallBackURL = "http://127.0.0.1:8000";
// Target Realtime Database and the node (table) objects are stored under.
FDatabase->DatabaseName = "<your-firebase-database>";
FDatabase->TableName = "Contacts";
// Persist tokens so the consent screen only appears on first run.
FDatabase->PersistTokens->Location = plIniFile;
FDatabase->PersistTokens->Key = TTMSFNCUtils::AddBackslash(TTMSFNCUtils::GetDocumentsPath())
+ FDatabase->ClassName() + ".ini";
FDatabase->LoadTokens();
FDatabase->OnConnected = DatabaseConnected;
FDatabase->Connect(); // opens the browser for consent on first run, then fires OnConnected
}
void __fastcall TForm1::DatabaseConnected(TObject *Sender)
{
FDatabase->SaveTokens();
// Safe to read or write objects now.
FDatabase->ReadList(FObjects);
}
Next steps
- Guides — authentication, defining a data model, and storing/reading objects.
- API reference — full class reference.