Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Working code example:</p> <pre><code>int port = 2195; String hostname = "gateway.sandbox.push.apple.com"; //load certificate string certificatePath = @"cert.p12"; string certificatePassword = ""; X509Certificate2 clientCertificate = new X509Certificate2(certificatePath, certificatePassword); X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate); TcpClient client = new TcpClient(hostname, port); SslStream sslStream = new SslStream( client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null ); try { sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, true); } catch (AuthenticationException ex) { client.Close(); return; } // Encode a test message into a byte array. MemoryStream memoryStream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(memoryStream); writer.Write((byte)0); //The command writer.Write((byte)0); //The first byte of the deviceId length (big-endian first byte) writer.Write((byte)32); //The deviceId length (big-endian second byte) String deviceId = "DEVICEIDGOESHERE"; writer.Write(ToByteArray(deviceId.ToUpper())); String payload = "{\"aps\":{\"alert\":\"I like spoons also\",\"badge\":14}}"; writer.Write((byte)0); //First byte of payload length; (big-endian first byte) writer.Write((byte)payload.Length); //payload length (big-endian second byte) byte[] b1 = System.Text.Encoding.UTF8.GetBytes(payload); writer.Write(b1); writer.Flush(); byte[] array = memoryStream.ToArray(); sslStream.Write(array); sslStream.Flush(); // Close the client connection. client.Close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload