推送通知在生产环境中不起作用

发布于 2024-09-03 04:26:23 字数 339 浏览 2 评论 0原文

当我在开发模式下运行我的应用程序时,我可以毫无问题地获取通过 PushMeBaby 发送给自己的推送通知。但是,当我尝试在生产环境中测试它时,我无法收到任何推送通知。我重新生成了所有证书和配置文件,使用 aps_product_identity.cer 作为推送通知的证书,将 SSL 更改为 gateway.push.apple.com,并为应用程序进行了发布构建,但仍然无法获得让它工作。我发现在 PushMeBaby 中,该行

result = SSLHandshake(context);

返回错误 -9844。这是否意味着 aps_product_identity.cer 文件有问题?

When I run my app in development mode, I can get the push notifications I send to myself through PushMeBaby without a problem. However, when I try to test it in the production environment, I can not get any push notifications. I re-generated all the certificates and provisioning profiles, used the aps_production_identity.cer as the certificate for push notifications, changed the SSL to gateway.push.apple.com, and did a release build for the app, but still couldn't get it to work. I found that in PushMeBaby, the line

result = SSLHandshake(context);

Returns error -9844. Does this mean that something is wrong with the aps_production_identity.cer file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小梨窩很甜 2024-09-10 04:26:23

是的,我已经解决了这个错误。我花了几天时间寻找解决方案。问题出在这一行:

result = SSLSetPeerDomainName(context, "gateway.sandbox.push.apple.com", 30);
NSLog(@"SSLSetPeerDomainName(): %d", result);

您必须将端口更改为数字 30。这可以解决问题。

Yes, I've solved this error. I lost a few days finding the solution. The problem is in the line:

result = SSLSetPeerDomainName(context, "gateway.sandbox.push.apple.com", 30);
NSLog(@"SSLSetPeerDomainName(): %d", result);

You have to change the port to number 30. This solves the problem.

俯瞰星空 2024-09-10 04:26:23

我认为最好不要在代码中硬编码这样的数字,即使它是示例代码。我认为 30 是一个端口号(对我没有进行更多代码评估感到羞耻)。

我将该行更改为如下所示:

#define kApplePushGateway "gateway.push.apple.com" //"gateway.sandbox.push.apple.com"

result = SSLSetPeerDomainName(context, kApplePushGateway, [[NSString stringWithUTF8String:kApplePushGateway] length]);
NSLog(@"SSLSetPeerDomainName(): %d", result);

I think it is better to not hardcode numbers like this in code, even if it is sample code. I thought that the 30 was a port number (shame on me for not doing more code evaluation).

I changed that line to something like this:

#define kApplePushGateway "gateway.push.apple.com" //"gateway.sandbox.push.apple.com"

result = SSLSetPeerDomainName(context, kApplePushGateway, [[NSString stringWithUTF8String:kApplePushGateway] length]);
NSLog(@"SSLSetPeerDomainName(): %d", result);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文