No previous blog, I show how retrieve um dispositivo token, now I will show how use o HTTP/2 sgcWebSockets client para enviar uma notificação (sem o autenticação part).
Send your remote notificação payload e device token information para serviço Apple Push Notificação (APNs).
How Conectar um APNs
Você deve use HTTP/2 protocol e pelo menos TLS 1.2 ou later para establish um bem-sucedido conexão entre your Server Provider e one do seguinte servers:
Development Server: https://api.sandbox.push.apple
Production Server: https://api.push.apple
Delphi Code
Create um novo instance de TsgcHTTP2Client e call o método POST para enviar uma notificação para APNs.
oHTTP := TsgcHTTP2Client.Create(nil);
Try
// ... requires authorization code
oStream := TStringStream.Create('{"aps":{"alert":"Alert from sgcWebSockets!"}}');
Try
oHTTP.Post('https://api.push.apple/3/device/device_token', oStream);
if oHTTP.Response.Status = 200 then
ShowMessage('Notification Sent Successfully')
else
ShowMessage('Notification error');
Finally
oStream.Free;
End;
Finally
oHTTP.Free;
End;
