2

i want to use APNS from Apple with a c# service. The service runs perfect. What i wanna have is the feedback from Apple if have send the pans to apple. So what i need is the feedback from a sslstream.

Can anybody help me and tell me how i gat a feedback from the server within the sslstream ?

Thanks in advance

Here is my code how i send sthe pans to the apple server :

    TcpClient client = new TcpClient(hostname, APNS_PORT);
    SslStream sslStream = new SslStream(
        client.GetStream(),
        false,
        new RemoteCertificateValidationCallback(ValidateServerCertificate),
        null
        );

     sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, true);

     sslStream.Write(array);
     sslStream.Flush();
user1201412
  • 31
  • 1
  • 3

2 Answers2

0

From this apple link: http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html

If you send a notification and APNs finds the notification malformed or otherwise unintelligible, it returns an error-response packet prior to disconnecting. (If there is no error, APNs doesn’t return anything.) Figure 5-3 depicts the format of the error-response packet.

I assume you just read back from the stream, however I haven't gotten this working yet myself. I've attempted sending malformed requests in an effort to reponse packet, however my read call gets blocked, seemingly waiting for the ANPS to respond.

midspace
  • 922
  • 9
  • 18
0

I got these code from APNS Sharp.

        if (!this.apnsStream.IsMutuallyAuthenticated)
        {
            if (this.Error != null)
            {
                this.Error(this, new NotificationException(4, "Ssl Stream Failed to Authenticate"));
            }
        }

        if (!this.apnsStream.CanWrite)
        {
            if (this.Error != null)
            {
                this.Error(this, new NotificationException(5, "Ssl Stream is not Writable"));
            }
        }

Where apnsStream is like you sslStream. I believe that those events could be the feedback that you are searching.

Marco Medrano
  • 2,530
  • 1
  • 21
  • 35