pushsharp 2在向Apple ios发送通知时触发异常 [英] pushsharp 2 fires an exception while sending notification to apple ios

查看:152
本文介绍了pushsharp 2在向Apple ios发送通知时触发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了PushSharp 2.0.4,并在向苹果发送通知时触发了异常:

I used PushSharp 2.0.4 and its fires an exception while sending notification to apple:

您已经选择了生产服务器,但是您的证书似乎不是生产证书!请检查以确保您具有正确的证书!

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!

我注意到由于苹果证书政策的变化,我认为在pushsharp 2中存在一个硬编码值,它引用了旧的证书名称.

I notice that due to change in apple certificate policies and i think there are a hard coded value in the pushsharp 2 that referee to the old certificate name.

到目前为止,我不想转移到新的pushsharp 3版本,但是我想在我的pushsharp 2.0代码中解决此问题.

I don't want to transfer to the new pushsharp 3 version till now but i want to fix this issue in my pushsharp 2.0 code.

我认为更改应该在ApplePushChannelSettings类中:

I think the change should be in ApplePushChannelSettings class:

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!");
}

但是我有一个问题要问之前遇到过这个问题的任何人,这是唯一应该做的更改吗?还要做什么正确的更改?或者具体说说,苹果用它代替了这个正确的值是什么?

But I have a question for any one faced this issue before, is this the only change should done and also what is the correct change to be done or to be specific what is the correct value that apple used instead of this?

更新: 我评论了ApplePushChannelSettings.cs中的某些行,引发异常的行以及仅正确发送给android的通知,并且该问题仍然存在于ios中.

Update: I commenting some lines in ApplePushChannelSettings.cs, the lines that fire exception, and the notifications sent correctly to android only and the issue still in ios.

推荐答案

我找到了一个解决方案,它与Windows上的证书配置有关.

I found a solution and it was related to certificate configuration on windows.

首先,您应该知道苹果对其证书政策和行为进行了微小的更改,因此您应该从PushSharp 2 tp PushSharp 3进行转换,您会在我的答案中找到有关升级的所有信息:

First of all you should to know that apple making a minor changes to it's certificates policies and behavior so you should convert from PushSharp 2 tp PushSharp 3 and you will found all about the upgrade here in my answer:

production-certificate-error-in-push-notification -pushsharp

此外,如果您有兴趣了解Apple所做的更改及其对PushSharp 2的反映,请检查: apple-push-services-created-instead-苹果生产iOS推送服务

Also if you are interested to know about the changes that apple make and how it reflect to PushSharp 2 check that: apple-push-services-created-instead-of-apple-production-ios-push-services

我还使用mmc将证书从用户帐户证书更改为本地计算机证书,并且我在上面的答案中禁用了模拟身份验证和所有详细信息,但是我不想再次重复.

also i used mmc to change certificate from user account certificate to local computer certificate and i disabled the impersonation authentication and the full details in my above answer but i don't want to repeat again.

这篇关于pushsharp 2在向Apple ios发送通知时触发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆