APN | Sending Notification Requests to APNs

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server

 

Send your remote notification payload and device token information to Apple Push Notification service (APNs).

 

How Connect to APNs

You must use HTTP/2 protocol and at least TLS 1.2 or later to establish a successful connection between your Server Provider and one of the following servers:

 

Development Server: https://api.sandbox.push.apple

Production Server: https://api.push.apple

 

Sample Code

Create a new instance of TsgcHTTP2Client and call the method POST to send a notification to APNs.

 


oHTTP := TsgcHTTP2Client.Create(nil);
Try
  // ... requires authorization code
  oStream := TStringStream.Create('{"aps":{"alert":"Alert from sgcWebSockets!"}}', 
    TEncoding.UTF8);
  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;

To send notifications, you must establish either token-based  or certificate-based trust with APNs using HTTP/2 protocol and TLS 1.2 or later.