can you help me to with this function
function TdmPush.GetDeviceRegistrationId: string;
begin
{$IFDEF ANDROID}
result := gcmn.RegistrationID;
{$ELSE}
result := 'Mobile Test';
{$ENDIF}
end;
function TdmPush.PushMessage(Pushmessage : string):string;
const
sendUrl = 'https://android.googleapis.com/gcm/send';
var
Params: TStringList;
AuthHeader: STring;
idHTTP: TIDHTTP;
SSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
idHTTP := TIDHTTP.Create(nil);
try
SslIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
idHTTP.IOHandler := SSLIOHandler;
idHTTP.HTTPOptions := [];
Params := TStringList.Create;
try
Params.Add('registration_id='+ GetDeviceRegistrationId());
Params.Values['data.message'] := Pushmessage;
idHTTP.Request.Host := sendUrl;
AuthHeader := 'Authorization: key=' + YOUR_API_ID;
idHTTP.Request.CustomHeaders.Add(AuthHeader);
IdHTTP.Request.ContentType := 'application/x-www-form- urlencoded;charset=UTF-8';
result := idHTTP.Post(sendUrl, Params);
finally
Params.Free;
end;
finally
FreeAndNil(idHTTP);
end;
end;
I need the function GetDeviceRegeistrationID
to return an array of registration id, so I can modify the Push method.
An example how to assign the text from the items of a TListView into an array of string.