APN生产证书未被PushSharp识别

我开发了一个iOS应用程序,它接收推送通知。 我使用PushSharp从.NET环境发送它们。 在发展的过程中,一切都变得美好了,推送成功了:

var push = new PushBroker(); var appleCert = File.ReadAllBytes(@"Utils\Cert.Development.p12"); push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "*******")); push.QueueNotification(new AppleNotification() .ForDeviceToken(token) .WithContentAvailable(1) ); push.StopAllServices(); 

现在,该应用程序已被批准,并在AppStore。 我已经生成了正确的生产证书:

 var push = new PushBroker(); var appleCert = File.ReadAllBytes(@"Utils\Cert.Production.p12"); push.RegisterAppleService(new ApplePushChannelSettings(true, appleCert, "*******")); push.QueueNotification(new AppleNotification() .ForDeviceToken(token) .WithContentAvailable(1) ); push.StopAllServices(); 

但是当我尝试从PushSharp发送推送,它会引发以下exception:

 You have selected the Production server, yet your Certificate does not appear to be the Production certificate! Please check to ensure you have the correct certificate! 

我很确定我已经遵循了所有的步骤。 我已经下载了与应用程序中设置的供应文件绑定的生产证书进行发布。 打开它并导出.p12。

我也确定我没有意外地使用开发,因为如果我将PushSharp设置为开发,使用最后一个证书,它会引发以下错误:

 You have selected the Development/Sandbox (Not production) server, yet your Certificate does not appear to be the Development/Sandbox (Not production) certificate! Please check to ensure you have the correct certificate! 

证书怎么既不是开发也不是生产?

有什么地方我可以validation文件? 请给我一些关于这个问题的意见,因为我不知道从哪里开始

苹果已经改变了名字。 请到ApplePushChannelSettings.cs并更改名称如下。

 if (production && !subjectName.Contains("Apple Production IOS Push Services")) 

 if (production && !subjectName.Contains("Apple Push Services")) 

我昨天更新过期的证书时需要这样做。 更改名称,重build它并上传到服务器,然后重新工作。

苹果推出了新的通用推送证书,可以连接到APN的生产和开发环境。这就是为什么生产证书通用名已经从苹果生产IOS推送服务改为苹果推送服务的原因。

您应该更改提供程序推送服务器上的代码以与新的通用名称兼容。

当您为.NET创build生产证书(.p12)时,请始终导出,如仅select证书。 看到附加的图像

http://davidbits.blogspot.in/2016/02/error-you-have-selected-production.html

在这里输入图像说明

问题是在PushSharp库中只是更新到版本.3这是因为苹果已经将推送证书名称从(苹果生产推送服务)(Apple推送服务)和pushSharp检查证书的名称:(生产&&!subjectName.Contains( “苹果推送服务”))。

错误:您已经select了生产服务器,
但你的证书看起来不是生产证书!
请检查以确保您拥有正确的证书!

解决scheme: (production && !subjectName.Contains("Apple Push Services"))

按照以下链接中的步骤生成生产SSL证书:

如何创buildAPNS证书

如果这不起作用,请仔细检查您的代码,确保您正在从正确的证书文件中读取,并将True传递给ApplePushChannelSettings

我build议使用3.0 nuget预览版本中的某些内容。 这个问题在这些版本中已经修复,不会被反向移植到2.x.

PushSharp 2.x> Push.Apple> ApplePushChannelSettings.cs

在ApplePushChannelSettings.cs中findDetectProduction()和CheckProductionCertificateMatching(),并用'.Contains(“Apple Push Services”)replace'.Contains(“Apple Production IOS Push Services”

发生这种情况是因为苹果将证书名称从“Apple生产IOS推送服务”更改为“Apple推送服务”,PushSharp通过证书名称来识别types(生产/开发)。