Jump to content

Christoph Schneider

Members
  • Content Count

    6
  • Joined

  • Last visited

Posts posted by Christoph Schneider


  1. Thank you Dave for this valuable information.

     

    Unfortunately, my app is still not working. I still see that the Push-Service is nil because the app writes "Push Service failed" into the memo.

    unit Unit1;
    
    interface
    
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      System.PushNotification,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
      FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        btnStart: TButton;
        procedure btnStartClick(Sender: TObject);
      private
        procedure OnServiceConChange(Sender: TObject; AChange: TPushService.TChanges);
        procedure OnRecNot(Sender: TObject; const ANotification: TPushServiceNotification);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.fmx}
    
    procedure TForm1.btnStartClick(Sender: TObject);
    var
      PushService: TPushService;
      ServiceConnection: TPushServiceConnection;
    begin
      try
        PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm);
        if not assigned(PushService) then
          Memo1.Lines.Add('Push Service failed')
        else begin
          Memo1.Lines.Add('Push Service created');
          ServiceConnection := TPushServiceConnection.Create(PushService);
          if not assigned(ServiceConnection) then
            Memo1.Lines.Add('Service Connection failed')
          else begin
            Memo1.Lines.Add('Service Connection created');
            ServiceConnection.Active := true;
            Memo1.Lines.Add('Service Connection connected');
            ServiceConnection.OnChange := OnServiceConChange;
            ServiceConnection.OnReceiveNotification := OnRecNot;
    
            Memo1.Lines.Add('Service Connection query');
            Memo1.Lines.Add('DeviceID: ' + PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceId]);
          end;
        end;
      except
        on e: exception do
          Memo1.Lines.Add('Failure: ' + e.Message);
      end;
    end;
    
    procedure TForm1.OnRecNot(Sender: TObject;
      const ANotification: TPushServiceNotification);
    var
      Msg: string;
    begin
      Msg := ANotification.DataObject.ToJSON;
      Memo1.Lines.Add('Message: ' + Msg);
    end;
    
    procedure TForm1.OnServiceConChange(Sender: TObject;
      AChange: TPushService.TChanges);
    var
      PushService: TPushService;
    begin
      if TPushService.TChange.DeviceToken in AChange then
      begin
        PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm);
        Memo1.Lines.Add('Firebase token: ' + PushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken]);
      end;
    end;
    
    end.

    I have enabled "Receive push notification" in the entitlement list:

    image.thumb.png.414f575f1b80d866978ca0b1f9bc11a9.png

     

    I have written the package name according the FB App setting:

     

    image.thumb.png.87b730001a25dbe66e7afcda32503ba2.png

     

    I imported my google-services.json in the Services section:

     

    image.thumb.png.b63b8dd265f7713ff000cb0ba15eaa54.png

     

    What I still not understand is point 14: Why I still need to build this strings.xml and attach it to the deployments? 

    In the new project options under Application>Services, I entered already both values (google application ID and the default sender id). 

     

    Of course, I tried also the described way by using strings.xml in the deployments under remote path res\values. Thanks to your ACTED tool I was able to convert my google-services.json into the following strings.xml:

     

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
      <string name="gcm_defaultSenderId" translatable="false">XXXXXXXXXX - MyNumber</string>
      <string name="google_app_id" translatable="false">XXXXXXXXXX - My App ID from Firebase Console</string>
      <string name="fcm_fallback_notification_channel_label" translatable="false">Notification channel for Firebase</string>
    </resources>

    Point 15: Changing the AndroidManifest.template.xml is no longer needed, right?

     

    Any changes in the section "Uses Permissions"?

     

     


  2. Is there an updated version of this good tutorial for De 10.3.2?  E.g. Firebase FMX package is no longer in the GetIt Package available and probably a lot of point works now different, but I cannot find any description or tutorial.

     

    PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm);

    When I try to execute the code built with De 10.3.2 the only what I can see is that PushService is still nil after this line. Probably something is wrong with my project settings for Android.


  3. For the Google Cloud database Firebase, there was no complete library for Delphi. The new open source library FB4D closes this gap and supports the Firebase Realtime DB, the new Firestore DB, the Firebase Storage (for file storage) and Firebase Functions (for calling server functions). 

    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 since Delphi 10 Seattle are supported. The library is a pure source code library and relies on class interfaces. 

    https://github.com/SchneiderInfosystems/FB4D

    The library offers a wiki. Two example applications and a Getting-Started on the wiki will help you to start working with the library.

    • Like 1
    • Thanks 2
×