Gary Wardell 0 Posted August 17, 2020 Hi, I am trying to follow this blog article that Marco Cantu wrote in 30 May 2019 to test push alerts. https://community.idera.com/developer-tools/b/blog/posts/firebase-android-push-notification-support-with-rad-studio-10-3-1 I have Delphi 10.3.2; I am getting TPushServiceConection is undeclared. I have uses System.PushNotification; and uses FMX.Pushnotification.Android;. What am I missing? Or is it called so0mething else now? Gary Share this post Link to post
Dave Nottage 553 Posted August 17, 2020 3 hours ago, Gary Wardell said: TPushServiceConection Is your code really missing one "n"? Share this post Link to post
Gary Wardell 0 Posted August 17, 2020 (edited) 2 hours ago, Dave Nottage said: Is your code really missing one "n"? Yes it was. It was late and I missed that. Now I am getting this: [DCC Error] Unit1.pas(59): E2009 Incompatible types: 'method pointer and regular procedure' [DCC Error] Unit1.pas(60): E2009 Incompatible types: 'method pointer and regular procedure' This is my code: procedure OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges); begin end; procedure OnReceiveNotificationEvent(Sender: TObject; const ServiceNotification: TPushServiceNotification); begin end; procedure TForm1.FormCreate(Sender: TObject); var PushService: TPushService; ServiceConection: TPushServiceConnection; FDeviceID: string; begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); ServiceConection := TPushServiceConnection.Create(PushService); ServiceConection.Active := True; ServiceConection.OnChange := OnServiceConnectionChange; <--------- ServiceConection.OnReceiveNotification := OnReceiveNotificationEvent; <--------- FDeviceID := PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceID]; MemoLog.Lines.Add('DeviceID: ' + FDeviceID); MemoLog.Lines.Add('Ready to receive.'); end; Edited August 17, 2020 by Sherlock Please use the code tags for improved readability Share this post Link to post
Dave Nottage 553 Posted August 17, 2020 40 minutes ago, Gary Wardell said: procedure OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges); This is a regular method. OnChange is an object method, so needs to be assigned to a method that is part of an object Share this post Link to post
Gary Wardell 0 Posted August 17, 2020 6 minutes ago, Dave Nottage said: This is a regular method. OnChange is an object method, so needs to be assigned to a method that is part of an object When I do this: procedure TForm1.OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges); begin end; procedure TForm1.OnReceiveNotificationEvent(Sender: TObject; const ServiceNotification: TPushServiceNotification); begin end; I get this: [DCC Error] Unit1.pas(42): E2003 Undeclared identifier: 'OnServiceConnectionChange' [DCC Error] Unit1.pas(42): E2029 ';' expected but '(' found [DCC Error] Unit1.pas(46): E2003 Undeclared identifier: 'OnReceiveNotificationEvent' [DCC Error] Unit1.pas(46): E2029 ';' expected but '(' found Sorry, but I am a bit of a novice. Gary Share this post Link to post
Sherlock 663 Posted August 17, 2020 What do you mean "when I do this"? Do you enter those procedure stumps without interface declaration? Please check the documentation on this http://docwiki.embarcadero.com/RADStudio/Rio/en/Procedures_and_Functions_(Delphi) Share this post Link to post
Gary Wardell 0 Posted August 17, 2020 1 minute ago, Sherlock said: What do you mean "when I do this"? I'll look at the link. What I meant is I added TForm1. to the name. If you look at the listing above you can see it was missing. Share this post Link to post
Sherlock 663 Posted August 17, 2020 OK, that is not enough. You need to expand the declaration of your TForm1 class to include the definition of those methods. I suggest you work through some form of Delphi primer first. Just to get to know the basics. Share this post Link to post
Gary Wardell 0 Posted August 17, 2020 2 minutes ago, Sherlock said: You need to expand the declaration of your TForm1 class Ok. I am following the examples that Marco wrote in that blog article. He obviously left out some details. Doing this: type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Label2: TLabel; Button1: TButton; MemoLog: TMemo; procedure BtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); Corrected that error. Now I am getting this error: Two lines of the code, copied from the blog article.: ServiceConection.OnChange := OnServiceConnectionChange; ServiceConection.OnReceiveNotification := OnReceiveNotificationEvent; [DCC Error] Unit1.pas(51): E2003 Undeclared identifier: 'OnServiceConnectionChange' [DCC Error] Unit1.pas(52): E2003 Undeclared identifier: 'OnReceiveNotificationEvent' Share this post Link to post
Sherlock 663 Posted August 17, 2020 Damned be those blogs... The target of this blog is obviously a more experienced clientele, and Marco failed to mention that. What you did in post #4 was half way right. You need to add the declaration of those methods in the interface of the class TForm1 as well - right after FormCreate should be fine. Share this post Link to post
Gary Wardell 0 Posted August 17, 2020 14 minutes ago, Sherlock said: right after FormCreate should be fine. Like this? procedure TForm1.FormCreate(Sender: TObject); var PushService: TPushService; ServiceConection: TPushServiceConnection; FDeviceID: string; procedure BtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); begin PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM); ServiceConection := TPushServiceConnection.Create(PushService); ServiceConection.Active := True; ServiceConection.OnChange := OnServiceConnectionChange; ServiceConection.OnReceiveNotification := OnReceiveNotificationEvent; FDeviceID := PushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceID]; MemoLog.Lines.Add('DeviceID: ' + FDeviceID); MemoLog.Lines.Add('Ready to receive.'); end; That didn't help. BTW. I have programed Pascal many years ago. And Delphi 7 and 8 some years ago. But I had some time doing other stuff and for got some things. And this bit seems not all that simple. Share this post Link to post
Sherlock 663 Posted August 17, 2020 Ummm, no. those methods are intended to be part of the class TForm1. So add those declarations to the class declaration: type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Label2: TLabel; Button1: TButton; MemoLog: TMemo; procedure BtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure BtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); Like this... Share this post Link to post
Gary Wardell 0 Posted August 17, 2020 5 hours ago, Sherlock said: to the class declaration: Hi, I looked and saw a BtnClick. I tried assigning that to the ServiceConection.OnChange and it didn't get an error. So I declared those procedures the same way and it worked. Sure helps to have examples that work. So now on to the next step. Thanks for your help. Gary Share this post Link to post
Sherlock 663 Posted August 18, 2020 OMG...I just saw, I copied the wrong declarations to the interface. My bad! Corrected here: type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Label2: TLabel; Button1: TButton; MemoLog: TMemo; procedure BtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure OnServiceConnectionChange(Sender: TObject; PushChanges: TPushService.TChanges); procedure OnReceiveNotificationEvent(Sender: TObject; const ServiceNotification: TPushServiceNotification); But good on you, that you spotted the problem and solved it! Share this post Link to post
Gary Wardell 0 Posted August 18, 2020 13 hours ago, Sherlock said: But good on you, that you spotted the problem and solved it! Hi, New problem. I can't find this. ----- 14. Navigate to Project > Deployment Manager and add the strings.xml file from your FireMonkey application project folder, i.e. C:\MyFireBaseApplication (see step 7). ----- How do I find the Deployment Manager? Where is it and step by step how do I get to it. I did some Google searches but that didn't help. Gary Share this post Link to post
Dave Nottage 553 Posted August 18, 2020 1 hour ago, Gary Wardell said: How do I find the Deployment Manager? In the IDE menu: Project|Deployment Share this post Link to post
Gary Wardell 0 Posted August 18, 2020 3 minutes ago, Dave Nottage said: Project|Deployment Hui, Thanks. I looked through the IDE and didn't see that. Gary Share this post Link to post
Gary Wardell 0 Posted August 18, 2020 23 minutes ago, Dave Nottage said: In the IDE menu: Project|Deployment Hi, Ok. I put the file in there and in the remote directory I think he said. And I saw the Deploy button, do I clicked that and it made the apk file. I copied that to my phone and installed it. But now when I tap on the app icon Android says the App has stopped. So, now can we get into debugging why the app has stopped? I am not familiar with how to debug apps on an Android phone. The apps I have written some time ago all just ran. They were all using Kinvey for alerts. It never displayed the one form it has in it. The phone is Motorola Z2 Play. Running android 8.0.0. I don't know if it makes a difference, I didn't code sign the app. Gary Share this post Link to post
Gary Wardell 0 Posted August 21, 2020 Hi, I found the problem so this question can be closed. My test app is now working and receiving notifications. Share this post Link to post
Sherlock 663 Posted August 21, 2020 So...what was the problem then? How did you solve it in the end? I bet there is somebody out there still fighting with this issue. 1 Share this post Link to post