PushSharp 无法识别 APN 生产证书 [英] APN Production certificate not being recognized by PushSharp

查看:23
本文介绍了PushSharp 无法识别 APN 生产证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个 iOS 应用,可以接收推送通知.我使用 PushSharp 从 .NET 环境发送它们.开发过程中一切顺利,推送成功:

I've developed an iOS app, that receives Push Notifications. I'm sending them from a .NET environment using PushSharp. Everything went beautifully while developing, and the Pushs were successfully sent:

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 上架.我已生成正确的生产证书:

Now, the app has been approved, and it's at AppStore. I have generate the correct production certificate:

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 发送推送时,它抛出以下异常:

but when I try to send the push from PushSharp, it throws the following 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.

I'm pretty sure I've followed all the steps. I've downloaded the production certificate that was binded with the provisioning file set in the app to publish. Opened it and exported the .p12.

我也确定我不是偶然使用开发的,因为如果我将 PushSharp 设置为开发,使用最后一个证书,它会抛出以下错误:

I'm also sure I'm not using a development one by accident, because, if I set PushSharp for development, using this last certificate, it throws the following error:

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!

证书怎么可能既不是Development,也不是Production?

有什么地方可以验证文件吗?请给我一些关于这件事的见解,因为我不知道从哪里开始

Is there somewhere I can validate the file? Please give me some insigth on this matter, as I have no clue where to start

推荐答案

Apple 已更改名称.请转到 ApplePushChannelSettings.cs 并更改名称如下.

Apple has changed the name. Please go to ApplePushChannelSettings.cs and change the name as below.

来自

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

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

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

I need to do this when I renewing my expired cert yesterday. Change the name, rebuild it and upload to server, then it's working again.

这篇关于PushSharp 无法识别 APN 生产证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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