C# 3.0 Apple推送通知反馈服务不工作

C# 3.0 Apple推送通知反馈服务不工作,c#-3.0,apple-push-notifications,C# 3.0,Apple Push Notifications,我正在开发一个使用苹果推送通知的iPhone应用程序。在iPhone端,一切都很好,在服务器端,我有一个问题。通知发送正确。但是,当我试图查询反馈服务以获取卸载应用程序的设备列表时,我总是得到零结果。我知道我应该得到一个结果,因为应用程序已从我的一个测试设备上卸载。24个多小时后,我仍然没有收到反馈服务的结果 有什么想法吗?有人知道反馈服务识别我的应用程序已从测试设备卸载需要多长时间吗 注意:我在设备上有另一个推送通知应用程序,因此我知道我的应用程序不是唯一的应用程序。 代码-C#: 卸载后一分

我正在开发一个使用苹果推送通知的iPhone应用程序。在iPhone端,一切都很好,在服务器端,我有一个问题。通知发送正确。但是,当我试图查询反馈服务以获取卸载应用程序的设备列表时,我总是得到零结果。我知道我应该得到一个结果,因为应用程序已从我的一个测试设备上卸载。24个多小时后,我仍然没有收到反馈服务的结果

有什么想法吗?有人知道反馈服务识别我的应用程序已从测试设备卸载需要多长时间吗

注意:我在设备上有另一个推送通知应用程序,因此我知道我的应用程序不是唯一的应用程序。

代码-C#:


卸载后一分钟内,您将收到反馈。

您是否尝试向卸载的应用程序发送推送通知?据我所知,反馈服务只发送推送通知传递失败的通知

    public static string CheckFeedbackService(string certaName, string hostName)
    {
        SYLogger.Log("Check Feedback Service Started");
        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
         // Create a TCP socket connection to the Apple server on port 2196
        TcpClient tcpClientF = null;
        SslStream sslStreamF = null;
        string result = string.Empty;
         //Contect to APNS& Add the Apple cert to our collection
        X509Certificate2Collection certs = new X509Certificate2Collection { GetServerCert(certaName) };
        //Set up
        byte[] buffer = new byte[38];
        int recd = 0;
        DateTime minTimestamp = DateTime.Now.AddYears(-1);
        // Create a TCP socket connection to the Apple server on port 2196
        try
        {
            using (tcpClientF = new TcpClient(hostName, 2196))
            {
                SYLogger.Log("Client Connected  ::" + tcpClientF.Connected);
                // Create a new SSL stream over the connection
                sslStreamF = new SslStream(tcpClientF.GetStream(), true,ValidateServerCertificate);
                // Authenticate using the Apple cert
                sslStreamF.AuthenticateAsClient(hostName, certs, SslProtocols.Default, false);
                SYLogger.Log("Stream Readable ::" + sslStreamF.CanRead);
                SYLogger.Log("Host Name ::"+hostName);
                SYLogger.Log("Cert Name ::" + certs[0].FriendlyName);

                if (sslStreamF != null)
                {
                    SYLogger.Log("Connection Started");

                            //Get the first feedback
                            recd = sslStreamF.Read(buffer, 0, buffer.Length);
                            SYLogger.Log("Buffer length ::" + recd);
                            //Continue while we have results and are not disposing
                            while (recd > 0)
                            {

                                        SYLogger.Log("Reading Started");
                                            //Get our seconds since 1970 ?
                                            byte[] bSeconds = new byte[4];
                                            byte[] bDeviceToken = new byte[32];
                                            Array.Copy(buffer, 0, bSeconds, 0, 4);
                                            //Check endianness
                                            if (BitConverter.IsLittleEndian)
                                                    Array.Reverse(bSeconds);
                                            int tSeconds = BitConverter.ToInt32(bSeconds, 0);
                                            //Add seconds since 1970 to that date, in UTC and then get it locally
                                            var Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tSeconds).ToLocalTime();
                                            //Now copy out the device token
                                            Array.Copy(buffer, 6, bDeviceToken, 0, 32);
                                            string deviceToken = BitConverter.ToString(bDeviceToken).Replace("-", "").ToLower().Trim();
                                            //Make sure we have a good feedback tuple
                                            if (deviceToken.Length == 64 && Timestamp > minTimestamp)
                                            {
                                                SYLogger.Log("Feedback " + deviceToken);
                                                result = deviceToken;
                                            }
                                            //Clear  array to reuse it
                                            Array.Clear(buffer, 0, buffer.Length);
                                           //Read the next feedback
                                           recd = sslStreamF.Read(buffer, 0, buffer.Length);
                            }
                SYLogger.Log("Reading Ended");
                }

            }

        }
        catch (Exception e)
        {
            SYLogger.Log("Authentication failed - closing the connection::" + e);
            return "NOAUTH";
        }
        finally
        {
            // The client stream will be closed with the sslStream
            // because we specified this behavior when creating the sslStream.
            if (sslStreamF != null) sslStreamF.Close();
            if (tcpClientF != null) tcpClientF.Close();
            //Clear array on error
            Array.Clear(buffer, 0, buffer.Length);
        }
        SYLogger.Log("Feedback ended ");
        return result;
    }