Delphi Can
Push Notification alamama - Baskı Önizleme

+- Delphi Can (https://www.delphican.com)
+-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3)
+--- Forum: Mobil Platform - FireMonkey (FMX) (https://www.delphican.com/forumdisplay.php?fid=7)
+--- Konu Başlığı: Push Notification alamama (/showthread.php?tid=5029)



Push Notification alamama - 41linea41 - 29-06-2020

Merhaba

Konsol üzerinden mesaj atmaya çalışıyorum ama telefona ulaşmıyor.
Push notification eklediğim sürümü henuz play store eklemedim. Debug modda tele yukledim.
Bildirim alamıyorum. Firebase token ı FMC jeton kısmına ekledim bu durumda sadece benim tele bildirim gelmesi gerekmez mi?

Firebase tarafı:

8nZCc6.png
OHIop5.png
5105na.png

Delphi tarafı:
açılışta firebase bilgilerini memo içinde kontrol ediyorum.
jbX95l.png

Kodlar:
procedure TfrmAna.FormCreate(Sender: TObject);
var
Uygulama_Servisi:IFMXApplicationEventService;

 PushService: TPushService;
 ServiceConnection: TPushServiceConnection;
 Notifications: TArray<TPushServiceNotification>;

begin


//PUSH NOTIFICATION AYARLARI
PushService :=
TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM);
  ServiceConnection := TPushServiceConnection.Create(PushService);
  ServiceConnection.Active := True;
  ServiceConnection.OnChange := OnServiceConnectionChange;
  ServiceConnection.OnReceiveNotification := OnReceiveNotificationEvent;

  FDeviceId :=
PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceId];
  MemoLog.Lines.Add('DeviceID: ' + FDeviceId);
  MemoLog.Lines.Add('Ready to receive!');

  // Checks notification on startup, if application was launched fromcold start
  // by tapping on Notification in Notification Center
  Notifications := PushService.StartupNotifications;
  if Length(Notifications) > 0 then
  begin
      MemoLog.Lines.Add('-----------------------------------------');
      MemoLog.Lines.Add('DataKey = ' + Notifications[0].DataKey);
      MemoLog.Lines.Add('Json = ' + Notifications[0].Json.ToString);
      MemoLog.Lines.Add('DataObject = ' +
Notifications[0].DataObject.ToString);
      MemoLog.Lines.Add('-----------------------------------------');
  end;


end;

uses kısmı:
    {$IFDEF ANDROID}
      FMX.PushNotification.Android,
 {$ENDIF}
 System.PushNotification,

Receive service procedure:
procedure TfrmAna.OnReceiveNotificationEvent(Sender: TObject;
  const ServiceNotification: TPushServiceNotification);
var
  MessageText: string;
begin
  MemoLog.Lines.Add('-----------------------------------------');
  MemoLog.Lines.Add('DataKey = ' + ServiceNotification.DataKey);
  MemoLog.Lines.Add('Json = ' + ServiceNotification.Json.ToString);
  MemoLog.Lines.Add('DataObject = ' +
ServiceNotification.DataObject.ToString);
  MemoLog.Lines.Add('---------------------------------------');

end;

procedure TfrmAna.OnServiceConnectionChange(Sender: TObject;
 PushChanges: TPushService.TChanges);
var
  PushService: TPushService;
begin
  PushService :=
TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM);
  if TPushService.TChange.DeviceToken in PushChanges then
  begin
      FDeviceToken :=
PushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken];
      MemoLog.Lines.Add('FireBase Token: ' + FDeviceToken);
      Log.d('Firebase device token: token=' + FDeviceToken);
  end;
  if (TPushService.TChange.Status in PushChanges) and (PushService.Status
= TPushService.TStatus.StartupError) then
      MemoLog.Lines.Add('Error: ' + PushService.StartupError);
end;

Örnek aldığım video:
youtube


Cvp: Push Notification alamama - Fesih ARSLAN - 30-06-2020

Merhaba,
Kodlarınızda herhangi bir sorun göremedim. Bir ara FCM Push Notification Console'unda bildirim gönderme sorunu vardı. Şu an düzeldi mi bilmiyorum. Bundan kaynaklı olabilir.  
Sunucu anahtarı ve token'ı ÖM ile gönderebilir misiniz? 
REST Debugger ile notification göndereyim, test edelim.