I need to help about Firebase Notification service using Delphi Fmx.
I created a acount in Google FireBase. I achieved Android Notification in Delphi Fmx.
I created p8 file in MAc OX and add Firebase.
Project Options Verion Info changed CFBundleIdentifier same bundle at Firebase
My code:
unit uMain;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo , System.IOUtils, System.PushNotification
{$IFDEF ANDROID},
FMX.PushNotification.Android
{$ENDIF}
{$IFDEF IOS}
,FMX.PushNotification.IOS
,FMX.PushNotification.FCM.iOS
{$ENDIF} ;
type
TfrmMain = class(TForm)
edt: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FDeviceId : String;
FDevicetoken : String;
FPushService: TPushService;
FPushServiceConnection: TPushServiceConnection;
procedure OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges);
procedure OnReceiveNotificationEvent(Sender: TObject; const ServiceNotification: TPushServiceNotification);
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.fmx}
procedure TfrmMain.FormCreate(Sender: TObject);
var
PushService: TPushService;
ServiceConnection: TPushServiceConnection;
Notifications: TArray<TPushServiceNotification>;
begin
PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.FCM);
ServiceConnection := TPushServiceConnection.Create(PushService);
ServiceConnection.OnChange := OnServiceConnectionChange;
ServiceConnection.OnReceiveNotification := OnReceiveNotificationEvent;
ServiceConnection.Active := True;
FDeviceId :=PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceId];
edt.Lines.Add('DeviceID: ' + FDeviceId);
edt.Lines.Add('Ready to receive!');
Notifications := PushService.StartupNotifications;
if Length(Notifications) > 0 then
begin
edt.Lines.Add('-----------------------------------------');
edt.Lines.Add('DataKey = ' + Notifications[0].DataKey);
edt.Lines.Add('Json = ' + Notifications[0].Json.ToString);
edt.Lines.Add('DataObject = ' +
Notifications[0].DataObject.ToString);
edt.Lines.Add('-----------------------------------------');
end;
end;
ServiceConnection.Active := True; give me error Acess Violatin
I colud to need to your recommend