IOS推送消息程序从2014-04-16开始连接不上APNS服务器gateway.sandbox.push.apple.com,报错信息为“从传输流收到意外的 EOF 或 0 个字节”,请问谁能知道具体是什么原因?十分感谢!
解决方案 »
- 怎么将图片文件读入数组
- Button上面添加一个手势UIGestureRecognizer
- 有在用appcelerator开发IPhone程序的吗
- 求助-IPAD 充电时,右上角,为什么会显现“没有充电”
- 手游开发程序员,晒晒你的工资是多少
- 用过eclipse的求教
- 请问有没有方法不通过APNS,而用本地通知来直接接收远程的推送消息
- iOS masonry自动布局怎么导入呢?导入masonry文件夹够不够呢?为什么我导入时报了很多个错呢?
- ios蓝牙开发 自动连接问题
- iOS 推送
- 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跪求各位兄弟,有无找到解决的方案,问题都出现一周了,很闹心呀