I used TRtcHttpClient and TRtcDataRequest and it works like a charm. The HttpClient you set to fcm.googleapis.com and you can call it like :
procedure TDMRTC_GF.SendMobileNotification(const ADestino, AMessage: String);
begin
RtcDataRequest.Request.Method := 'POST';
RtcDataRequest.Request.FileName:='/fcm/send';
RtcDataRequest.Request['Content-Type']:='application/json';
RtcDataRequest.Request['Authorization']:='key=<insert my google key here>'; // here come your key
With RtcDataRequest.Request.Info.newRecord('data') do begin
asText['to']:= ADestino;
with newRecord('data') do
asText['message'] := AMessage;
end;
RtcDataRequest.Post;
end;
procedure TDMRTC_GF.RtcDataRequestBeginRequest(Sender: TRtcConnection);
begin
With TRtcDataClient(Sender) do
Write(Request.Info.asJSON['data']);
end;
procedure TDMRTC_GF.RtcDataRequestDataReceived(Sender: TRtcConnection);
var S: String;
begin
With TrtcDataClient(Sender) do
If TrtcDataClient(Sender).Response.Done then begin
S := TrtcDataClient(Sender).Read;
CodeSite.Send( csmLevel4, 'Google Response', S);
end;
end;