![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 6 of 6 total |
![]() |
Mon, Jul 10 2017 9:45 PM | Permanent Link |
KimHJ Comca Systems, Inc | I move my ServerRequest from my form over to a new unit and now I'm not able to set the OnComplete procedure, I get Expected variant or method but instead found GCMNotificationOnComplete. It worked fine with the Form.
If I run it with out GCMNotificationComplete I get an Error: '$t' is undefined unit FireNotification; interface uses WebCore,WebHTTP; procedure SNotification(GCMCustomerID,GMCmessage, GMCTitle: String); procedure GCMNotificationComplete(Request: TServerRequest); implementation procedure SNotification(GCMCustomerID,GMCmessage, GMCTitle: String); var GCMNotification: TServerRequest; begin GCMNotification := TServerRequest.Create(nil); with GCMNotification do begin try Method:=rmPost; URL:=GCMURL; RequestHeaders.Clear; RequestHeaders.Values['Authorization']:='key=' + FCMServerID; RequestHeaders.Values['Content-Type']:='application/json'; RequestContent.Clear; RequestContent.add('{"to": ' + QuotedStr(GCMCustomerID,DOUBLE_QUOTE) + ',"notification": {"title": ' + QuotedStr(GMCTitle,DOUBLE_QUOTE) + ',"body": ' + QuotedStr(GMCmessage,DOUBLE_QUOTE) + '},"priority": "high"}'); OnComplete := GCMNotificationComplete; Execute; finally Free; End; end; end; procedure GCMNotificationComplete(Request: TServerRequest); begin if (Request.StatusCode <> HTTP_OK) then begin end; end; Thanks for any help. Kim |
Tue, Jul 11 2017 3:21 AM | Permanent Link |
Matthew Jones | KimHJ wrote:
> procedure GCMNotificationComplete(Request: TServerRequest); That needs to be a member of an object somehow. Create a notification manager object, and put it all in that. -- Matthew Jones |
Tue, Jul 11 2017 11:01 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Kim,
<< I move my ServerRequest from my form over to a new unit and now I'm not able to set the OnComplete procedure, I get Expected variant or method but instead found GCMNotificationOnComplete. It worked fine with the Form. >> As Matthew indicates, you're using a procedure instead of a method, hence the compiler error. All of the callbacks in EWB are event handlers (methods) and not functions like they are in plain JavaScript. Tim Young Elevate Software www.elevatesoft.com |
Tue, Jul 11 2017 6:46 PM | Permanent Link |
KimHJ Comca Systems, Inc | >>As Matthew indicates, you're using a procedure instead of a method, hence the compiler error. All of the >>callbacks in EWB are event handlers (methods) and not functions like they are in plain JavaScript.
Ok I may not have done this right because I get an Error; Unable to get property 'tnotification_snotification' of undefined or null reference. TNotification = class private public procedure SNotification(GCMCustomerID,GMCmessage, GMCTitle: String); procedure GCMNotificationComplete(Request: TServerRequest); end; procedure TNotification.SNotification(GCMCustomerID,GMCmessage, GMCTitle: String); Thanks, Kim |
Tue, Jul 11 2017 7:59 PM | Permanent Link |
Raul ![]() | On 7/11/2017 6:46 PM, KimHJ wrote:
> Ok I may not have done this right because I get an Error; Unable to get property 'tnotification_snotification' of undefined or null reference. > > TNotification = class > private > public > procedure SNotification(GCMCustomerID,GMCmessage, GMCTitle: String); > procedure GCMNotificationComplete(Request: TServerRequest); > end; > > procedure TNotification.SNotification(GCMCustomerID,GMCmessage, GMCTitle: String); Did you create an actual instance of the TNotification and make sure it's not freed when OnComplete fires ? 1. you'd basically need to do declare it var MyNotification:TNotification; 2. and then create it MyNotification:= TNotification.Create 3. and then assing it as Oncomplete handler ServerRequest1.OnComplete := MyNotification.GCMNotificationComplete; Assuming it's on its own unit then you can declare it in the same unit and then create when app starts and you can use it for all your server requests then Raul |
Wed, Jul 12 2017 11:53 AM | Permanent Link |
KimHJ Comca Systems, Inc | Raul wrote:
>>2. and then create it >> MyNotification:= TNotification.Create Thanks, I forgot this part. Kim |
This web page was last updated on Sunday, April 27, 2025 at 01:25 AM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |