Search code examples
androiddelphifiremonkey

Need help understanding why this function returns null


I am writing a Delphi Android app to use Google Push.

Here is the function in question. It always returns null:

var
  PushService: TPushService;
  Notifications: TArray<TPushServiceNotification>;
  ServiceConnection: TPushServiceConnection;
begin
  PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm);
  Memo1.Lines.Add('PushService');
  if not assigned(PushService) then
    Memo1.Lines.Add('PushService error')
  else begin
    Memo1.Lines.Add('PushService ok');
    PushService.AppProps[TPushService.TAppPropNames.GCMAppID] := '543546532983';
    ServiceConnection := TPushServiceConnection.Create(PushService);

Solution

  • TPushService.TServiceNames.Gcm (Google cloud messaging) is deprecated, as that service is no longer provided by Google. You need to use TPushService.TServiceNames.FCM (Firebase cloud messaging) instead.

    See Firebase Android Support in Embarcadero's documentation for details on how to register, configure, and use FCM in your app.