你能帮我用这个功能吗
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 方法。