Marco Cantu 78 Posted May 31, 2019 Offers Java files and interfaces, along with steps, for adding Android Firebase client support in FMX apps. http://blog.marcocantu.com/blog/2019-05-android-firebase-patch-blog.html 4 Share this post Link to post
Christoph Schneider 5 Posted September 6, 2019 (edited) Is there an updated version of this good tutorial for De 10.3.2? E.g. Firebase FMX package is no longer in the GetIt Package available and probably a lot of point works now different, but I cannot find any description or tutorial. PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm); When I try to execute the code built with De 10.3.2 the only what I can see is that PushService is still nil after this line. Probably something is wrong with my project settings for Android. Edited September 6, 2019 by Christoph Schneider Share this post Link to post
Dave Nottage 557 Posted September 6, 2019 (edited) With 10.3.2, there's just a few of the steps needed from the original tutorial: https://community.idera.com/developer-tools/b/blog/posts/firebase-android-push-notification-support-with-rad-studio-10-3-1 Which are: 8 through 10, 14, one step that's actually missing from the tutorial: In Project Options, select Application > Version Info and modify the value for "package" to match the identifier you have for the project in Firebase Console and one additional step, which is what I expect you may be missing, namely: In Project Options, select Application > Entitlement List, and check the Receive Push Notifications checkbox. I think that's everything 🙂 Edited September 6, 2019 by Dave Nottage Share this post Link to post
Christoph Schneider 5 Posted September 7, 2019 (edited) Thank you Dave for this valuable information. Unfortunately, my app is still not working. I still see that the Push-Service is nil because the app writes "Push Service failed" into the memo. unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.PushNotification, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; btnStart: TButton; procedure btnStartClick(Sender: TObject); private procedure OnServiceConChange(Sender: TObject; AChange: TPushService.TChanges); procedure OnRecNot(Sender: TObject; const ANotification: TPushServiceNotification); end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.btnStartClick(Sender: TObject); var PushService: TPushService; ServiceConnection: TPushServiceConnection; begin try PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm); if not assigned(PushService) then Memo1.Lines.Add('Push Service failed') else begin Memo1.Lines.Add('Push Service created'); ServiceConnection := TPushServiceConnection.Create(PushService); if not assigned(ServiceConnection) then Memo1.Lines.Add('Service Connection failed') else begin Memo1.Lines.Add('Service Connection created'); ServiceConnection.Active := true; Memo1.Lines.Add('Service Connection connected'); ServiceConnection.OnChange := OnServiceConChange; ServiceConnection.OnReceiveNotification := OnRecNot; Memo1.Lines.Add('Service Connection query'); Memo1.Lines.Add('DeviceID: ' + PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceId]); end; end; except on e: exception do Memo1.Lines.Add('Failure: ' + e.Message); end; end; procedure TForm1.OnRecNot(Sender: TObject; const ANotification: TPushServiceNotification); var Msg: string; begin Msg := ANotification.DataObject.ToJSON; Memo1.Lines.Add('Message: ' + Msg); end; procedure TForm1.OnServiceConChange(Sender: TObject; AChange: TPushService.TChanges); var PushService: TPushService; begin if TPushService.TChange.DeviceToken in AChange then begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.Gcm); Memo1.Lines.Add('Firebase token: ' + PushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken]); end; end; end. I have enabled "Receive push notification" in the entitlement list: I have written the package name according the FB App setting: I imported my google-services.json in the Services section: What I still not understand is point 14: Why I still need to build this strings.xml and attach it to the deployments? In the new project options under Application>Services, I entered already both values (google application ID and the default sender id). Of course, I tried also the described way by using strings.xml in the deployments under remote path res\values. Thanks to your ACTED tool I was able to convert my google-services.json into the following strings.xml: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="gcm_defaultSenderId" translatable="false">XXXXXXXXXX - MyNumber</string> <string name="google_app_id" translatable="false">XXXXXXXXXX - My App ID from Firebase Console</string> <string name="fcm_fallback_notification_channel_label" translatable="false">Notification channel for Firebase</string> </resources> Point 15: Changing the AndroidManifest.template.xml is no longer needed, right? Any changes in the section "Uses Permissions"? Edited September 7, 2019 by Christoph Schneider Share this post Link to post
just_moldy 1 Posted January 11, 2021 Hello, I don't know if someone still follows this post, but I want to share my experience with Delphi push notifications: Using 10.4 to create an Android app, when running the following code : uses System.PushNotification; PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.FCM); PushService was always nil. I tried everything I found on the internet, but nothing worked. The magical solution: use FMX.PushNotification.Android, System.PushNotification; I hope this will save some time for someone. 1 Share this post Link to post