Jump to content
MirDurmaz

Ios Notification Error

Recommended Posts

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 

Share this post


Link to post

I suceesded to get deviceId but take the Token give me error:

A valid "aps-enviroment" authorization key was not found for the application

Share this post


Link to post
Just now, MirDurmaz said:

A valid "aps-enviroment" authorization key was not found for the application

Does the App ID you are using have Push Notification entitlement?:

image.thumb.png.7ffb0a546325aa1039ec4fe068d0f8ab.png

 

You set this on the Apple Developer website. If you have not already set this entitlement, after you do so you will need to recreate the Provisioning Profile

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×