Ver Mensaje Individual
  #4  
Antiguo 13-12-2022
giantonti1801 giantonti1801 is offline
Miembro
 
Registrado: oct 2022
Posts: 143
Reputación: 2
giantonti1801 Va por buen camino
Enviar notificaciones Push desde Escritorio

hola amigos estoy haciendo una aplicacion que me permite enviar notificaciones push a dispositivo. mi desarrollo esta hecho el delphi 11 con notificaciones push en firebase, ya tengo instalada sdk en el telefono y recibe perfecto cuando mando las notificaciones desde firebase. ahora paso el codigo en un evento on click para enviar la notificaciones a movil, donde en edit coloco el token del dispositivo y en el memo un mensaje:
Código Delphi [-]
var
  Msg: string;
  s1, s2: TMemoryStream;
  hd: TArray ;
  st: String;
  b: TBytes;
  devicetoken: string;

begin
  deviceToken := Trim(EditToken.Text);

  Msg := 'Mi primer notificación Push.';

  s1 := TMemoryStream.Create;
  s2 := TMemoryStream.Create;

  try
    NetHTTPClient1.ContentType := 'application/json';

    st := '{' +
        '"to": "'+deviceToken+'",' +
        '"notification":{"priority":"hight",' +
        '"title":"Título de la Notificación",'+
        '"body":"'+Msg+'",'+
        '"dry_run":"false"}'+
      '}';

    setlength(hd, 1);

    b := TEncoding.UTF8.GetBytes(st);

    s1.Write(b, length(b));
    s1.Position := 0;

    hd[0].Name:='Authorization';
    hd[0].Value:='AAAAxZyP0LM:APA91bErnP8pAKD2x**************************************************************  **********************************An7GMJq6QUvXjrZgR_Rr3fxC2z';

    NetHTTPClient1.Post('https://fcm.googleapis.com/fcm/send', s1, s2, hd);

    s2.Position := 0;

    { Mostramos el resultado devuelto por FCM }
    memoGCM.Lines.LoadFromStream(s2, TEncoding.UTF8);
  finally
    s1.Free;
    s2.Free;
  end;
end;

el enviar el mensaje me sale un error que dice que le falta autorizacin y aunque he investigado como y en donde colocar esta aurorizacion ademas de no logro entender de que autorizacion se trata y en donde encontrarla, a comtinuacion le envio el mensaje de error:
Código PHP:
<HTML>
<
HEAD>
<
TITLE>The request was missing an Authentication KeyPleaserefer to section &quot;Authentication&quotof the FCM documentationat https://firebase.google.com/docs/cloud-messaging/server.</TITLE>
</HEAD>
<
BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<
H1>The request was missing an Authentication KeyPleaserefer to section &quot;Authentication&quotof the FCM documentationat https://firebase.google.com/docs/cloud-messaging/server.</H1>
<H2>Error 401</H2>
</
BODY>
</
HTML
alguien puede ayudarme con eso porque en firebase todo es super confuso.
Responder Con Cita