Beppe Magistro 1 Posted December 21, 2020 hi all, i have an application builded with Delphi 10.3.3 and android firebase notification are working good. I tried to move the application to Delphi 10.4.1 but the app hang when try to connect the server. PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); ServiceConnection := TPushServiceConnection.Create(PushService); ServiceConnection.Active := True; i Tried with a small example from the scratch but the same result. anybody has a working example on 10.4.1 ? Thanks in advance Beppe Share this post Link to post
Dave Nottage 557 Posted December 21, 2020 7 minutes ago, Beppe Magistro said: TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM) Please pay attention to compiler warnings. TPushService.TServiceNames.GCM has been deprecated. Use TPushService.TServiceNames.FCM Share this post Link to post
Beppe Magistro 1 Posted December 21, 2020 Hi Dave, i tried TPushService.TServiceNames.FCM but same result ,the program hang when execute ServiceConnection.Active := True; There is a tutorial or an example for 10.4.1 ? Thanks Beppe Share this post Link to post
Guest Posted December 21, 2020 https://stackoverflow.com/questions/62264578/delphi-android-firebase-cloud-messaging-application-crashes-on-notification-re Share this post Link to post
Beppe Magistro 1 Posted December 21, 2020 16 minutes ago, emailx45 said: https://stackoverflow.com/questions/62264578/delphi-android-firebase-cloud-messaging-application-crashes-on-notification-re this is not my case , on 10.3.3 my app is working , the problem is on 10.4.1 Share this post Link to post
Guest Posted December 21, 2020 have tryed add the "KEYs/IDs" in project as expected when using a API services by Google/Apple etc..? Share this post Link to post
Beppe Magistro 1 Posted December 21, 2020 13 minutes ago, emailx45 said: have tryed add the "KEYs/IDs" in project as expected when using a API services by Google/Apple etc..? yes the same as 10.3.3 Share this post Link to post
Dave Nottage 557 Posted December 21, 2020 8 hours ago, Beppe Magistro said: program hang when execute What do you mean by hang? Have you checked to see if PushService is non-nil when executing this line? ServiceConnection := TPushServiceConnection.Create(PushService); Share this post Link to post
Beppe Magistro 1 Posted December 22, 2020 15 hours ago, Dave Nottage said: What do you mean by hang? Have you checked to see if PushService is non-nil when executing this line? ServiceConnection := TPushServiceConnection.Create(PushService); PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); ServiceConnection := TPushServiceConnection.Create(PushService); ServiceConnection.Active := True;<<<<---- app hang here Share this post Link to post
Dave Nottage 557 Posted December 30, 2020 3 hours ago, Beppe Magistro said: up You didn't answer my other question, i.e: On 12/22/2020 at 11:39 PM, Beppe Magistro said: Have you checked to see if PushService is non-nil when executing this line? ServiceConnection := TPushServiceConnection.Create(PushService); Share this post Link to post
Guest Posted December 30, 2020 (edited) Here all step-by-step to use Sydney / Android / TPushService / Firebase Support uses FMX.PushNotification.Android; procedure TFormMain.FormCreate(Sender: TObject); var PushService: TPushService; ServiceConnection: TPushServiceConnection; Notifications: TArray<TPushServiceNotification>; begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.FCM); 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; // it's good idea verify if the service was started! if (PushService.Status = TPushService.TStatus.Started) then begin ... end http://docwiki.embarcadero.com/RADStudio/Sydney/en/Firebase_Android_Support hug Edited December 30, 2020 by Guest Share this post Link to post
Beppe Magistro 1 Posted December 30, 2020 17 hours ago, emailx45 said: Here all step-by-step to use Sydney / Android / TPushService / Firebase Support uses FMX.PushNotification.Android; procedure TFormMain.FormCreate(Sender: TObject); var PushService: TPushService; ServiceConnection: TPushServiceConnection; Notifications: TArray<TPushServiceNotification>; begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.FCM); 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; // it's good idea verify if the service was started! if (PushService.Status = TPushService.TStatus.Started) then begin ... end http://docwiki.embarcadero.com/RADStudio/Sydney/en/Firebase_Android_Support hug hi , this example do not compile on 10.4.1 , PushService: TPushService; ServiceConnection: TPushServiceConnection; Notifications: TArray<TPushServiceNotification>; these variables remain in red , may be are not more defined in FMX.PushNotification.Android; if i include System.PushNotification; the sample compile but hang Share this post Link to post
Guest Posted December 30, 2020 this sample is from Embarcadero not my! Not my fault or guilt! look address: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Firebase_Android_Support Share this post Link to post
Beppe Magistro 1 Posted December 30, 2020 17 hours ago, Dave Nottage said: You didn't answer my other question, i.e: PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.FCM); if PushService <> nil then begin ...... remain nil ! Share this post Link to post
Dave Nottage 557 Posted December 30, 2020 1 hour ago, Beppe Magistro said: these variables remain in red , may be are not more defined in FMX.PushNotification.Android; Are you actually including that unit in your source? If so, where you have declared it, please use Ctrl-Click or right-click and Open File At Cursor. It should find it in the Delphi source in the fmx folder. If it finds it anywhere else, that's probably the issue. Share this post Link to post
Guest Posted December 30, 2020 FMX.Platform.TPlatformServices.SupportsPlatformService(...) = OK??? Share this post Link to post
Beppe Magistro 1 Posted December 31, 2020 20 hours ago, emailx45 said: FMX.Platform.TPlatformServices.SupportsPlatformService(...) = OK??? ?? 1 Share this post Link to post