Git Product home page Git Product logo

fb4d's Introduction

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 and anonymous login.

The library builds on the Firebase REST-API and provides all functionality with synchronous and asynchronous methods for the usage within GUI application, services and background threads. Both frameworks VCL and Firemonkey are supported. The library is a pure source code library and 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 important library enhancements that need the attention of users of this library.

  • August 2024: Refactoring and many improvements in DemoFB4D
  • 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.
  • 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 delete document too. The new 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
  • October 2021: Prepared for Delphi Alexandria
  • April 7, 2021: Revised RT DB Listener
  • March 2021: New optional cache to accelerate the repeated access to storage objects. Additional IFirebaseStorage.GetAndDownload method in order to simplify the download from the storage. See more details
    New option in FB4D.SelfRegistrationFra framework to support enter display name and upload 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.0 Athens.

🔺 This library requires at least Delphi 10.3 Rio Update 2 🔺.

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 version are no longer supported because of an issue in the RTL.

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, 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

Limitation on Android for VisionML

AnnotateFile is limited to pdf only, as gif support does not work due 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 tif image format is not yet supported by FMX.Graphics. You cannot convert an 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.

For older versions up to 10.4.2, you must note the following RSP: Due to a bug in the Linux RTL, all HTTP requests that transfer data to the server by using the Patch method are not working. Put and Post methods work. This affects the Realtime DB method Patch and the Firestore method InsertOrUpdateDocument for both synchronous and asynchronous accesses. For more information see RSP-33177.

Submodules

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

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

Logo FB4D

fb4d's People

Contributors

arvanus avatar christophschneidertrihow avatar dependabot[bot] avatar rafaelwerner avatar schneiderinfosystems avatar ybrovin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fb4d's Issues

SendEmailVerification

Request
When a user registers with an email/password. Be able to check the email used.

Solution
in FB4D.Interfaces.pas

IFirebaseAuthentication = interface(IInterface)
[...]
    procedure SendEmailVerification(const idToken: string; OnResponse: TOnResponse; OnError: TOnRequestError);
    procedure SendEmailVerificationSynchronous(const idToken: string);
[...]

in FB4D.Authentication.pas

[...]
procedure TFirebaseAuthentication.SendEmailVerification(const idToken: string; OnResponse: TOnResponse;
  OnError: TOnRequestError);
var
  Data: TJSONObject;
  Params: TDictionary<string, string>;
  Request: IFirebaseRequest;
begin
  Data := TJSONObject.Create;
  Request := TFirebaseRequest.Create(GOOGLE_PASSWORD_URL, Format('User Token to send the email %s', [idToken]));
  Params := TDictionary<string, string>.Create;
  try
    Data.AddPair(TJSONPair.Create('requestType', 'VERIFY_EMAIL'));
    Data.AddPair(TJSONPair.Create('idToken', idToken));
    Params.Add('key', ApiKey);
    Request.SendRequest(['getOobConfirmationCode'], rmPost, Data, Params, tmNoToken, OnResponse, OnError);
  finally
    Params.Free;
    Data.Free;
  end;
end;

procedure TFirebaseAuthentication.SendEmailVerificationSynchronous(const idToken: string);
var
  Data: TJSONObject;
  Params: TDictionary<string, string>;
  Request: TFirebaseRequest;
  Response: IFirebaseResponse;
  ds: TStringDynArray;
begin
  Data := TJSONObject.Create;
  Request := TFirebaseRequest.Create(GOOGLE_PASSWORD_URL);
  Params := TDictionary<string, string>.Create;
  try
    Data.AddPair(TJSONPair.Create('requestType', 'VERIFY_EMAIL'));
    Data.AddPair(TJSONPair.Create('idToken', idToken));
    Params.Add('key', ApiKey);
    ds := ['getOobConfirmationCode'];
    Response := Request.SendRequestSynchronous(ds, rmPost, Data, Params, tmNoToken);
    if not Response.StatusOk then
      Response.CheckForJSONObj;
  finally
    Response := nil;
    Params.Free;
    Request.Free;
    Data.Free;
  end;
  //
end;
[...]

Sorry not to proceed with a pull request but the code is fast to implement.
Thank you for this excellent library.

Security

Can you please tell me how best to implement security programmatically using FB4D.
RealtimeDatabase
I'm storing User data underneath a node where the name of the node = the User's email address. How can I restrict access programmatically so that only a User with the correct email address can read and write data to that node?
Storage
Likewise, I'm storing documents within a folder where the folder name = the User's email address.
How can I restrict access programmatically so that only a User with the correct email address can read and write documents to that folder?

firebase function no query parameters recevied ?

HI again,

I am trying to call my firebase functiono with parameters key and uid but the library is not sending any parameters in request.
here is the code i tried.

 params := TJSONObject.Create;
 params.AddPair('uid', UID);
 params.AddPair('key', '95871234');
 fConfig.Functions.CallFunction(onFucntion, onError, 'doLogin', params);

but in the firebase log console i found that the library does not sends any params ? why and one more thing in your firebase functions class you're readding the params object ot another object :

procedure TFirebaseFunctions.CallFunction(OnSuccess: TOnFunctionSuccess;
  OnRequestError: TOnRequestError; const FunctionName: string;
  Params: TJSONObject);
var
  Request: IFirebaseRequest;
  Data: TJSONObject;
begin
  fOnSucess := OnSuccess;
  fOnError := OnRequestError;
  Data := TJSONObject.Create;
  try
    Data.AddPair('data', Params);
    Request := TFirebaseRequest.Create(BaseURL,
      Format(rsFunctionCall, [FunctionName]), fAuth);
    Request.SendRequest([FunctionName], rmPost, Data, nil, tmBearer,
      OnResp, OnRequestError);
  finally
    Data.Free;
  end;
end; 

and you haven't mentioned it in any document.

how to correctly send query params ?

TFirestoreDocuments.CreateFromJSONArr on Query offset and limit (second page)

Is your feature request related to a problem? Please describe.
TFirestoreDocuments.CreateFromJSONArr
where Query return second page of limit and offset, first node return readTime, and second and others nodes, return DOCUMENT node

Describe the solution you'd like
hard coded
`
for c := 0 to fJSONArr.Count - 1 do
begin
Obj := fJSONArr.Items[c] as TJSONObject;

if (fJSONArr.Count = 1) and (Obj.Pairs[0].JsonString.Value = 'readTime') then
  // Empty [{'#$A'  "readTime": "2018-06-21T08:08:50.445723Z"'#$A'}'#$A']
  SetLength(fDocumentList, 0)
else if (fJSONArr.Count = 1) and (Obj.Pairs[0].JsonString.Value <> 'document') then
  raise EFirestoreDocument.CreateFmt(rsInvalidDocNode,
    [Obj.Pairs[0].JsonString.ToString])
else if (fJSONArr.Count = 1) and not(Obj.Pairs[0].JsonValue is TJSONObject) then
  raise EFirestoreDocument.CreateFmt(rsInvalidDocNode,
    [rsNotObj + Obj.ToString])
else if (Obj.Pairs[0].JsonString.Value = 'document') then
begin
  SetLength(fDocumentList, length(fDocumentList) + 1);
  fDocumentList[length(fDocumentList) - 1] :=
    TFirestoreDocument.CreateFromJSONObj(
      Obj.Pairs[0].JsonValue as TJSONObject);
end;

end;
`

Describe alternatives you've considered
try if exists documents

Implement all features in TStructuredQuery

unit FB4D.Firestore

Is your feature request related to a problem? Please describe.
orderBy, startAt, endAt, offset and limit not implemented

Describe the solution you'd like
implement orderBy, startAt, endAt, offset and limit options in TStructuredQuery

Incorrect number of parameters on method SendRequestSynchronous

The number of parameters of method call "SendRequestSynchronous" (e.g. line 85 in the library FB4D.OAuth.pas) does not match the defined number of parameters.
For this reason none of the sample projects can be compiled.

To reproduce the error, simply compile the test project "Intro".
[dcc32 Fehler] FB4D.OAuth.pas(86): E2250 Es gibt keine überladene Version von 'SendRequestSynchronous', die man mit diesen Argumenten aufrufen kann

How i get subcollection name

i have structure :
/mycollection/0MV82xezmrVhn5PJ6gG89aVVTdf1/s4czwD2Jo2Ab3tPGivDo

can i get "s4czwD2Jo2Ab3tPGivDo" with Runquery?

thanks
Allies xposs

Unable to Load OpenSSL Error on android

i am testing the new delphi 10.3.2 so i tried to load the "Firebase Lib Demo" on my android phone.
but when the app opens and i fill in the info needed then i click "Anonymous Login" i get this error

(Sign in with email for [email protected] failed : [RSA] Unable to Load OpenSSL Libraries)

please help
thanks

Can't make the CloudClipBoard connect under android

Hi,

Thanks for your work! it's a piece of art very useful for the Delphi community.
I've started testing the CloudClipBoard demo. I've created a test Firebase project and It works as expected under windows 10.
I've registered the project in the Google Firebase console and also registered the CloudClipBoard FMX Android application. I've set the package name and the App SHA-1.
But still CloudClipBoard demo is not able to connect to the firebase Authentication under Android 9.
It gets waiting on the "please wait for firebase" Screen forever.
I'm running Delphi 10.2 with Update 3. Is there any document that describes the steps to make the app run under Android (Settings for Firebase, for the app, etc.)
Thanks a lot!

2 or more simultaneous async RunQuery calling only the last passed TOnDocuments procedure

While developing Android app using FB4D code, I faced with the problem that makes Android app functioning incorrectly.
Stuck on this problem now.

I run 2 asynchronous queries, each has its own TOnDocuments and TOnRequestError callback procedures:

fDatabase.RunQuery([ 'Companies', a_company_id ], TStructuredQuery.CreateForSelect(['department_name']) .Collection('departments') , OnGetDepartmentsOK, OnGetDepartmentsError, NIL);
//... a few lines of code here ...
fDatabase.RunQuery([ 'Companies', a_company_id ], TStructuredQuery.CreateForSelect(['location_name','latitude','longitude','distance']) .Collection('locations') , OnGetLocationsOK, OnGetLocationsError, NIL);

WHAT IS WRONG:

For both queries results called TOnDocuments procedure that was passed as argument in the LAST called RunQuery.
I.e., for 'departments' query called OnGetLocationsOK callback procedure (THIS IS WRONG), but not OnGetDepartmentsOK as required/expected.
For the 'locations' query, also called OnGetLocationsOK, and this is correct.

How to surpass this situation ?
I need each RunQUery to call its own on-success callback procedure.

SendRequestSynchronous

Hey , i a new o delphi and i am trying to use your demo, but when a i run, i get: FB4D.Oauth there is no overload version of "SendRequestSynchronous" that can be called with this arguments. I really don't now what to do.

TFirestoreDatabase.GetSynchronous response with an Exception instead of nil when no document is available

Describe the bug
The TFirestoreDatabase.GetSynchronous method has another reaction then the asynchronous TFirestoreDatabase.Get when a requested path does not point to an existing node.

To Reproduce
Steps to reproduce the behavior:

  1. Call TFirestoreDatabase.GetSynchronous for a nonexistent path.
  2. Check the response

Expected behavior
As a result of the method TFirestoreDatabase.GetSynchronous nil is expected.

Real behavior
An exception of EFirebaseResponse is thrown.

Additional context
All platforms are affected

Storage Upload: JSON field downloadtokens missing.

Describe the bug
Using the Intro Demo App when I attempt to upload a file to File Storeage an error is returned from the Firebase server "JSON field downloadtokens missing."

To Reproduce
Steps to reproduce the behavior:

  1. Run DemoFB4D.exe
  2. Login
  3. Select Storeage Tab
  4. Enter Storage bucket
  5. Click on Upload
  6. Select File for Upload
  7. See error "JSON field downloadtokens missing."

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Browser [chrome]

RTDB Get method deleting child nodes automaticlly

whenever i try to use Get method it erases all nodes and writes timestamp in database.
this is the code i am using:

 // Clicking on btnLogin
procedure TForm3.BtnLoginClick(Sender: TObject);
begin
  if not Assigned(fConfig) then
    fConfig := TFirebaseConfiguration.Create(cApiKey, cId);
  fConfig.Auth.SignInWithEmailAndPassword(Edit1.Text, Edit2.Text,
    onUserResponse, onError);
end; 

//Log In Success
procedure TForm3.onUserResponse(const Info: string; user: IFirebaseUser);
begin
  UID := user.UID;
  pass := Edit2.Text;
  Email := user.Email;
  fConfig.RealTimeDB.GetServerVariables(cServerVariableTimeStamp, GetRTDBPath,
    onServerStamp, onError);
  Text1.Text := UID;
end; 

//Getting ServerTime for Usage
procedure TForm3.onServerStamp(const ServerVar: string; Val: TJSONValue);
var
  ST: int64;
begin
  ST := StrToInt64(Val.Value);
  sDate := TTimeZone.Local.ToLocalTime(UnixToDateTime(ST div 1000));
  SaveUser;
  UpdateLoginStatus;
end; 

//Trying to get data to use but is not getting at all 
procedure TForm3.UpdateLoginStatus;
begin
  fConfig.RealTimeDB.Get(GetRTDBPath, onGetResponse, onError);
end; 

//updating LoggedIn Status
procedure TForm3.onGetResponse(ResourceParams: TRequestResourceParam;
  Val: TJSONValue);
var
  sValue: TJSONObject;
begin
  ShowRTNode(ResourceParams, Val);

  //Below Will be used later once data is received 
  {sValue := TJSONObject.Create;
  try
    sValue.AddPair('LoggedIn', 'True');
    fConfig.RealTimeDB.Patch(GetRTDBPath, sValue, ShowRTNode, onError);
  finally
    sValue.Free;
  end;}
end;

when i try to get Data it deletes all the nodes and then creates a timestamp in path.

Why so ?

Get Online Users

Hello, thank you once again for this beautiful project. I want to attract Online users for RealTimeDB. Is there a solution for this or a procedure we can do?

TRealTimeDB.ListenForValueEvents calling ListenEvent and other events without TThread.Queue

Is your feature request related to a problem? Please describe.
I have a problem with the TRealTimeDB.ListenForValueEvents, when I use this method, I receive the data changed in realtime database in the main thread, so I need to receive it in a thread. In my case, I do not update any UI ( user interface ), I update tables of my database, and the process of updating my database is thread safe, so I am interfering in the main UI thread and I do not need that.

Describe the solution you'd like
I would like to have any properties to decide if I want the call to the events : ListenEvent, OnStopListening, OnError and OnAuthRevoked in the main UI thread ( TThread.Queue ) or without TThread.Queue.

Describe alternatives you've considered
publishing the properties ListenEventQueued : Boolean, StopListeningQueued : Boolean, ErrorQueued : Boolean and AuthRevokedQueued : Boolean with default values to true, would allow to run the new version of the library without migration problems when any user decide to update to the last version of the library. For example, if ListenEventQueued is true, the library would make the call to TThread.Queue ... fOnListenEvent(EventName, Params, JSONObj) and if ListenEventQueued if false, would make a direct call to the fOnListenEvent(EventName, Params, JSONObj) event without using TThread.Queue.

Thank you.

Persist IFirestoreDocument in memory

For the work process read / display / change / save, a document (IFirestoreDocument) must be temporarily stored in the memory.
I miss the possibility to create a clone of the read document for later use (e.g change and save an item value).

In the event "OnFirestoreGet" you can use "TFirestoreDocument.CreateFromJSONObj(Docs.Document(c).AsJSON)" to create an IFirestoreDocument based on the read document, but the items will be lost as soon as the event is left, since they're only referenced and not assigned.

Thank you for your efforts

Storage.UploadFromStream results in error

Describe the bug
The Intro demo program uses Storage.UploadSynchronousFromStream to demonstrate upload of a file.
This works perfectly. I need to implement the asynchronous alternative for Android use.

When I replace the Call using Storage.UploadFromStream I get an error every time

"Invalid HTTP method/URL pair."

To Reproduce
Steps to reproduce the behavior:

  1. Open the Intro demo project
  2. From line 704 rplace
    try
    fs := TFileStream.Create(OpenDialog.FileName, fmOpenRead);
    try
    fFirestoreObject := Storage.UploadSynchronousFromStream(fs, ObjectName,ContentType);
    ShowFirestoreObject;
    finally
    fs.Free;
    end;
    finally
    Storage.Free;
    end;
    end;

with
try
fs := TFileStream.Create(OpenDialog.FileName, fmOpenRead);
try
// fFirestoreObject := Storage.UploadSynchronousFromStream(fs, ObjectName,ContentType);
// ShowFirestoreObject;
Storage.UploadFromStream(fs, ObjectName, ContentType, nil, nil);
finally
// fs.Free;
end;
finally
// Storage.Free;
end;
end;

  1. Compile and run the into demo
  2. Invoke the file upload to witness the error

Desktop (please complete the following information):

  • OS: [Windows 10]

Set an array using a string when using AddOrUpdateField

When you add an Array using AddOrUpdateField, can you set the array using a string? (see sample below). Thanks ray
jValue: TJSONValue;
st: string;
st := '{"name", "John Smith", "age"}';
jValue := TJSONObject.ParseJSONValue(st);
Doc.AddOrUpdateField(TJSONObject.SetArray('MyArr', jValue));

RunQuery with Sub Collection

Is your feature request related to a problem? Please describe.
I need run RunQuery with a path concat in TFirebaseRequest URL

Describe the solution you'd like
update method RunQuery and RunQuerySynchronous and add a arg
DocPath and concat at TFirebaseRequest.Create
Request := TFirebaseRequest.Create(BaseURI + DocPath + METHODE_RUNQUERY, '', fAuth);

Can we Query for elements within arrays?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Get with auth

Hi my friends...

Is possible request a data with auth? When I request data with this parameters on my project, appears the message: Get failed: Permission denied (Get is an example, but path, put, delete have same error)

my firebase rules:

{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}

tks a lot!

Leo

Encoding problem with Real Time DB

Hope all is well, thanks again for you great work
Using the Firebase Lib Demo, I added Node to the Real Time DB, but the Value in the node contains Arabic letters. When I go to “Scan Real Time DB Event” tab and then activate “Notify Event Handler”
The node with Arabic letters are displayed using JsonUTF8 (\u00D8\u00B0\u00D9\u2021\u00D8)
I tried using TJSONValue to get the Arabic letters back but it’s not working
LJSONValue:=TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(order_info.GetValue('Name').ToJSON),0);
Showmessage(LJSONValue.ToString);
Can you please help; it looks like the function fRealTimeDB.ListenForValueEvents has a problem when getting the Arabic letters for google
Thanks

Problems with RealTimeDB listen for value event

Hi
Having some problems with RealTimeDB listen for value event.
To get the values from RealTimeDB I have to run this command two or three time to get the values??

if not CheckAndCreateRealTimeDBClass(memScans) then
exit;
fFirebaseEvent := fRealTimeDB.ListenForValueEvents
(SplitString(edtRTDBEventPath.Text.Replace('', '/'), '/'), OnRecData,
OnRecDataStop, OnRecDataError);

Some time I get this error list below then I get the values from the RealTimeDB, can you please help why not from the first time I send the command fRealTimeDB.ListenForValueEvents I get the values from the RealTimeDB?? Is there a limit from google with the size of the data received??

7:10:38 PM: Event handler started for RTimeDB_store1
7:10:39 PM: +Error in Exception in event parser: Stream read error
7:10:39 PM: +Error in Exception in event parser: Stream read error
7:10:39 PM: +Error in Exception in event parser: Stream read error
7:10:39 PM: +Error in Exception in event parser: Stream read error

7:10:39 PM: put[RTimeDB_store1] = {"path":"/","data":{"04-01-20_17-07-38-399":{…..(deleted the code its long)

Async Upload on Android fails

Using the new sample Intro program it is possible to exercise all Storage Upload and Download functions Synchronous and Asynchronous. They all work perfectly - in Windows.

Excercising the same functions on Android all work except for Asynchronous Upload. When Exercising asynchronous upload function the following exceptions occur
EHTTPProtocolException HTTP/1/1 400 Bad Request
followed by
EFirebaseResponse Invalid HTTP Method/URLpair.

To Reproduce

  1. Create a blank Muti-device application

  2. Add the FB4d.DemoFMX.pas form

  3. Discard the default main form

  4. Edit the program to use hard coded object names etc rather than the openfile dialog methods

  5. Compile and run under Windows

  6. Enter credentials and login

  7. UploadAsynchronous a file (that works fine under Windows)

  8. Close application

  9. Compile and deploy for Android

  10. Login

  11. Exercise GetAsynchronous function (for the file you previously uploaded - this works fine)

  12. Exercise UploadAsynchronous - This fails with the above exceptions
    (Interestingly UploadSynchronous works fine in Android)

Expected behavior
Android Asynchronous Upload behaviour should be identical to that of Windows.

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Delphi Rio
  • Android 7

Problem with Get Storage

When you set the edtStoragePath for imgs/ then you use btnUploadSynch, the folder will be created and the file uploaded successfully, but when you use btnGetStorageSynch an error occurs (Invalid Http Method/url Pair.) !?

thanks

How to create query to Firestore with "AND" conditions ?

Dear FB4D Creator,
please advise how with FB4D to create query to Firestore, that contains 'AND' in WHERE condition?

I need to select from a collection (AllUsers) all documents that have fields 'user_email'=specific_email AND 'user_active'=1.

Something like in python will be

AllUsers.where(u'user_email', u'==', specific_email).where(u'user_active', u'==', 1)

I'm trying with FB4D following, however it doesn't' work correct, because applying only the last condition ('user_active'=1), and removing first condition ('user_email'=specific_email):

fDatabase.RunQuery(
  TStructuredQuery.CreateForSelect( ['user_email','user_active', 'company_id','department_id', 'user_role'] )
    .Collection( AllUsers )
    .QueryForFieldFilter(
        TQueryFilter.StringFieldFilter('user_email', woEqual,
                             specific_email ))
    .QueryForFieldFilter(
        TQueryFilter.IntegerFieldFilter('user_active', woEqual,
                             1 ))
      .Limit( 5 )
        ,
      OnDocumentsOk, OnRequestError, Query);

Please advise, how to make 'AND in WHERE in a proper way?

Parameter has same name as property

In Unit FB4D.Authentification

constructor TFirebaseAuthentication.Create(const ApiKey: string);
begin
inherited Create;
fApiKey := ApiKey;
end;

the parameter ApiKey has the same name as the property ApiKey.
Perhaps better: Rename parameter to aApiKey:

constructor TFirebaseAuthentication.Create(const aApiKey: string);
begin
inherited Create;
fApiKey := aApiKey;
end;

Greetings from Christian

Json values

Hello. I'm new in json and firebase, i want return json get format form realtime data base

-MPKMpDkyJdq2c6ftItt: {"CompilerVersion":33,"PackageVersion":260,"Product":"Delphi 10.3 Rio","ProductVersion":26}

-MPKZIRnGXSCqG2V3LUq: {"CompilerVersion":33,"PackageVersion":260,"Product":"Delphi 10.3 Rio","ProductVersion":26}

-MPKdv8oH1CconMiQOg1: {"CompilerVersion":"Rzak","DataBaseID":"DATE1","PackageVersion":"5.1","Product":"Bonbon","ProductVersion":"2.10"}

to

{"-MPKMpDkyJdq2c6ftItt":{"CompilerVersion":33,"PackageVersion":260,"Product":"Delphi 10.3 Rio","ProductVersion":26}
,
"-MPKZIRnGXSCqG2V3LUq":{"CompilerVersion":33,"PackageVersion":260,"Product":"Delphi 10.3 Rio","ProductVersion":26}
,
"-MPKdv8oH1CconMiQOg1":{"CompilerVersion":"Rzak","DataBaseID":"DATE1","PackageVersion":"5.1","Product":"Bonbon","ProductVersion":"2.10"}}

Sorry for my bad english, im french. Thank You!

Inform in IRealTimeDB.ListenForValueEvents if a automatic token refresh was done

Is your feature request related to a problem? Please describe.

When the Real Time DB listener runs longer than an hour the authentication token needs to be renewed. This is done automatically by the listener but the caller does not get an event.

Describe the solution you'd like

In Addition, to ListenEvent, OnStopListening, and OnError a new OnTokenRefresh is required.

TokenJWT unclared

Hey me again :)
Sooo when a try to use ur sources, i keep getting error on both TokenJWT (ETokenJWT ITokenJWT). The error is that both ara undeclared, how i fix this ?

Stopping the Event Handler deletes the data in the RealTime db.

Hi
I created multiple Nodes using “Put” command in the lib demo app, then activated ‘Notify Event Handler’ in the “Scan Real Time DB Event” tab. When I stop the event handler the nodes I created are deleted in the RealTime db?! I want to delete them manually not automatically when I stop the event handler.

Is there a way to not delete the nodes automatically in the RealTime db when I Stop the Event Handler?
thanks

IOS device error Undeclared identifier: 'GetCryptLibHandle'

I imported the code I needed from DemoFB4D to my project and its working on android but when I try to run it on my IOS device I get this error , Can you please help

[DCC Error] JOSE.Signing.RSA.pas(370): E2003 Undeclared identifier: 'GetCryptLibHandle'
[DCC Warning] JOSE.Signing.RSA.pas(370): W1023 Comparing signed and unsigned types - widened both operands
[DCC Fatal Error] JOSE.Core.JWA.Signing.pas(37): F2063 Could not compile used unit 'JOSE.Signing.RSA.pas'

get pure json from document FireStore

Is there any way to get the pure json from the Fireastore document without MapValue like doubleValue, integerValue.
from
"produto":{"integerValue":"22"}
to
"produto":"22"

thanks;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.