【发布时间】:2016-02-24 12:47:44
【问题描述】:
我使用了 PushSharp 2.0.4,它在向苹果发送通知时触发了一个异常:
您已选择生产服务器,但您的证书似乎不是生产证书!请检查以确保您拥有正确的证书!
我注意到由于苹果证书政策的变化,并且我认为 pushsharp 2 中有一个硬编码值,用于引用旧证书名称。
到目前为止,我不想转移到新的 pushsharp 3 版本,但我想在我的 pushsharp 2.0 代码中解决这个问题。
我认为更改应该在 ApplePushChannelSettings 类中:
private void CheckProductionCertificateMatching(bool production)
{
if (this.Certificate == null)
{
throw new ArgumentNullException("You must provide a Certificate to connect to APNS with!");
}
string name = this.Certificate.IssuerName.Name;
string name2 = this.Certificate.SubjectName.Name;
if (!name.Contains("Apple"))
{
throw new ArgumentException("Your Certificate does not appear to be issued by Apple! Please check to ensure you have the correct certificate!");
}
if (production && !name2.Contains("Apple Production IOS Push Services") && !name2.Contains("Apple Push Services"))
{
throw new ArgumentException("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!");
}
if (!production && !name2.Contains("Apple Development IOS Push Services") && !name2.Contains("Pass Type ID"))
{
throw new ArgumentException("You have selected the Development/Sandbox (Not production) server, yet your Certificate does not appear to be the Development/Sandbox certificate! Please check to ensure you have the correct certificate!");
}
}
在这一行:
if (production && !name2.Contains("Apple Production IOS Push Services") && !name2.Contains("Apple Push Services"))
{
throw new ArgumentException("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!");
}
但我有一个问题想问任何人之前遇到过这个问题,这是唯一应该做的改变,还有什么是正确的改变,或者具体来说,苹果使用的正确值是什么?
更新: 我评论了 ApplePushChannelSettings.cs 中的一些行、引发异常的行以及仅正确发送到 android 的通知,而问题仍然存在于 ios。
【问题讨论】: