Apple Push Notifications

Send APNs push notifications from Delphi over HTTP/2 to api.push.apple.com. Supports both certificate-based and token-based (JWT ES256) authentication.

TsgcHTTP2Client + TsgcHTTP_JWT_Client

Pair TsgcHTTP2Client (HTTP/2 transport) with TsgcHTTP_JWT_Client (ES256 token minting) to drive APNs — the combo Apple recommends since the legacy binary protocol was retired.

Component class

TsgcHTTP2Client + TsgcHTTP_JWT_Client

Protocol

APNs HTTP/2

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Standard / Professional / Enterprise

Sign a JWT, POST the alert, watch HTTP/2 status

Configure TsgcHTTP_JWT_Client with your APNs ES256 private key and key/team IDs, link it to TsgcHTTP2Client.Authentication.Token.JWT, then POST the JSON payload to /3/device/<token>.

uses
  sgcHTTP, sgcBase_Helpers;

var
  HTTP2: TsgcHTTP2Client;
  JWT: TsgcHTTP_JWT_Client;
begin
  JWT := TsgcHTTP_JWT_Client.Create(nil);
  JWT.JWTOptions.Header.alg := jwtES256;
  JWT.JWTOptions.Header.kid := 'APPLE-KEY-ID';
  JWT.JWTOptions.Payload.iss := 'APPLE-TEAM-ID';
  JWT.JWTOptions.Payload.iat := StrToInt64(GetDateTimeUnix(Now, False));
  JWT.JWTOptions.Algorithms.ES.PrivateKey.LoadFromFile('AuthKey_XXX.p8');
  JWT.JWTOptions.RefreshTokenAfter := 40 * 60;

  HTTP2 := TsgcHTTP2Client.Create(nil);
  HTTP2.TLSOptions.IOHandler := iohSChannel;
  HTTP2.Authentication.Token.JWT := JWT;
  HTTP2.Request.CustomHeaders.Clear;
  HTTP2.Request.CustomHeaders.Add('apns-topic: com.example.app');

  HTTP2.Post(
    'https://api.push.apple.com/3/device/',
    '{"aps":{"alert":"hello","sound":"default"}}');
end;
// uses: sgcHTTP
TsgcHTTP_JWT_Client *JWT = new TsgcHTTP_JWT_Client(this);
JWT->JWTOptions->Header->alg = jwtES256;
JWT->JWTOptions->Header->kid = "APPLE-KEY-ID";
JWT->JWTOptions->Payload->iss = "APPLE-TEAM-ID";
JWT->JWTOptions->Algorithms->ES->PrivateKey->LoadFromFile("AuthKey_XXX.p8");

TsgcHTTP2Client *HTTP2 = new TsgcHTTP2Client(this);
HTTP2->Authentication->Token->JWT = JWT;
HTTP2->Request->CustomHeaders->Add("apns-topic: com.example.app");
HTTP2->Post("https://api.push.apple.com/3/device/", payload);

What's inside

Two cooperating components handle APNs end-to-end — HTTP/2 framing and JWT minting.

Token-based auth

ES256 JWTs signed with your Apple AuthKey_*.p8 private key. The JWT client refreshes the token automatically every 40 minutes (Apple expects rotation within an hour).

Certificate-based auth

For legacy universal certificates, set TLSOptions.CertFile + Password and clear Authentication.Token.JWT. The TLS handshake authenticates the connection.

Production / Sandbox

Point the URL at api.push.apple.com for production or api.development.push.apple.com for the sandbox — same component, just a different host.

apns-topic + headers

Set Request.CustomHeaders for apns-topic, apns-priority, apns-push-type, apns-collapse-id, apns-expiration per Apple's documentation.

HTTP/2 multiplexing

A single TLS connection sends thousands of pushes per minute — HTTP/2 streams multiplex the requests. Inspect Response.Status per call for delivery results.

SChannel or OpenSSL

Use iohSChannel on Windows for kernel-mode TLS (no DLLs needed) or iohOpenSSL for cross-platform server deployments.

Specifications & references

Authoritative sources for the APIs this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Online Help — TsgcHTTP2Client Full property, method and event reference for this component.
Demo Project — Demos\20.HTTP_Protocol\07.Apple_Push_Notifications Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.

Apple Push Frequently Asked Questions

Common questions about sending APNs notifications from Delphi and C++ Builder.

Pair a TsgcHTTP2Client (HTTP/2 transport) with a TsgcHTTP_JWT_Client (ES256 token minting). Configure the JWT client with your APNs key ID, team ID and .p8 private key, link it to HTTP2.Authentication.Token.JWT, set the apns-topic header, then POST the JSON payload to https://api.push.apple.com/3/device/<token>.
Both. For token-based auth, TsgcHTTP_JWT_Client mints ES256 JWTs from your Apple AuthKey_*.p8 key and refreshes them automatically (Apple expects rotation within an hour). For legacy certificate auth, set TLSOptions.CertFile and Password and clear Authentication.Token.JWT, so the TLS handshake authenticates the connection.
Yes. TsgcHTTP2Client speaks the APNs HTTP/2 API that replaced the retired binary protocol. A single TLS connection multiplexes thousands of pushes per minute over HTTP/2 streams, and you read Response.Status per call for delivery results. TLS runs through Windows SChannel (iohSChannel) or OpenSSL (iohOpenSSL).
sgcWebSockets supports Delphi 7 through the latest Delphi release and the matching C++ Builder versions, on Windows, macOS, Linux, iOS and Android. Download the free trial to integrate Apple Push Notifications into your own project.

Ready to Send APNs Pushes from Delphi?

Download the free trial and integrate Apple Push Notifications into your Delphi applications.