开发者

Push notifications not working in the production environment

When I run my ap开发者_如何学Gop 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?


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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜