本文介绍了如何修改了一项功能,它会返回一个字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你能帮助我与此功能
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;
我需要的功能 GetDeviceRegeistrationID
返回注册ID的数组,这样我就可以修改Push方法。
I need the function GetDeviceRegeistrationID
to return an array of registration id, so I can modify the Push method.
推荐答案
这是例子如何从一个的TListView的项目文本分配到字符串数组。
An example how to assign the text from the items of a TListView into an array of string.
function TdmPush.GetDeviceRegistrationId: TArray<string>;
var
i: Integer;
begin
SetLength(Result, myListView.Items.Count);
...
// Fill the array
for i := 0 to myListView.Items.Count-1 do
Result[i] := myListView.Items[i].Text;
end;
这篇关于如何修改了一项功能,它会返回一个字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!