IOS推送消息程序从2014-04-16开始连接不上APNS服务器gateway.sandbox.push.apple.com,报错信息为“从传输流收到意外的 EOF 或 0 个字节”,请问谁能知道具体是什么原因?十分感谢!
解决方案 »
- iOS消息推送除了苹果官方的APNS,还有其他的方法吗?
- @@如何关闭在storyboards中设置的popover方式打开的view?@@
- 程序在模拟器上运行正确,release的时候报错说找不到图标的文件
- 如何在tableveiw里建个group,将tableview里的东西分类!!
- 讨论个接口设计问题关于NSMutableArray的
- 有关Objective-C 的僵尸异常问题
- 在选中textfield的时候选中里面所有文字,请问怎么实现?
- IOS滑动问题求解释 求帮忙
- ios 录音格式问题
- 静态库制作的team ID问题
- UIPageViewController页面加个按钮,如何点击后进入下一页,上一页
- 我做的程序,大家帮赞点人气啊
{
//测试
string hostIP = "gateway.sandbox.push.apple.com";//
//正式
//string hostIP = "gateway.push.apple.com";
int port = 2195;
string password = "123456";//
string certificatepath = "aps_development.p12";
//string certificatepath = "aps_production.p12";
//这里面证书路径一定要注意了
string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"App_Code/", certificatepath);
certificate = new X509Certificate2(System.IO.File.ReadAllBytes(p12Filename), password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); certificates = new X509CertificateCollection();
certificates.Add(certificate);
TcpClient apnsClient = new TcpClient();
apnsClient.Connect(hostIP, port); SslStream apnsStream = new SslStream(apnsClient.GetStream(), false, new RemoteCertificateValidationCallback(validateServerCertificate), new LocalCertificateSelectionCallback(selectLocalCertificate)); try
{
//SSL可以换不同的试试
apnsStream.AuthenticateAsClient(hostIP, certificates, System.Security.Authentication.SslProtocols.Default, false);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
Console.WriteLine("error:" + ex.Message);
} if (!apnsStream.IsMutuallyAuthenticated)
{
Console.WriteLine("error:" + "Ssl Stream Failed to Authenticate");
} if (!apnsStream.CanWrite)
{
Console.WriteLine("error:" + "Ssl Stream is not Writable");
}
Byte[] message = ToBytes();
try
{
apnsStream.Write(message);
}
catch (Exception ex)
{
throw ex;
}
apnsStream.Close();
Console.WriteLine("success:" + "Ssl Stream is Writable" + ",message is " + Convert.ToBase64String(message));
Console.ReadLine();
}
//
apnsStream.AuthenticateAsClient(hostIP, certificates, System.Security.Authentication.SslProtocols.Default, false);SslProtocols.Default,用这个测试可以
https://developer.apple.com/library/ios/technotes/tn2265/_index.html跪求各位兄弟,有无找到解决的方案,问题都出现一周了,很闹心呀