Marcelo
Marcelo

Reputation: 76

Push notifications not working in the production environment

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?

Upvotes: 2

Views: 3018

Answers (2)

ucangetit
ucangetit

Reputation: 2655

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

Upvotes: 1

Marcelo
Marcelo

Reputation: 19

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.

Upvotes: 1

Related Questions