As the title says, I have an app with built in APNS. It does work perfectly in Sandbox-mode. But in production-mode, it fails miserably.
It seems that I have the right certificates on the server, because I don't get an error back from the APNS-Service. Everything seems to work fine. I am using ApnsPHP by Aldo Armiento. It has a built-in function to spit out the results from the APNS-Server. When I try to use the Sandbox with the app from the store, I get - as expected - an invalid-token-error (since tokens from sandbox and production are different). When I use the production-certificate with the app from the store, I don't get an error. Nothing, nada, zilch - it seems like it delivered the notification. Alas, it doesn't arrive on my phone.
So apparently, the certificates must be ok. It connects to the server, it sends the notification, all passes without errors (I did have wrong certificates first, so I know what happens if they're not right :)
Any ideas how to find out where the bug hides?
[Edit] here's what I get back from the APNS-Service:
Tue, 03 Jan 2012 03:13:55 +0100 ApnsPHP[13049]: INFO: Trying ssl://gateway.push.apple.com:2195...
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: INFO: Connected to ssl://gateway.push.apple.com:2195.
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: INFO: Sending messages queue, run #1: 1 message(s) left in queue.
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: STATUS: Sending message ID 1 [custom identifier: Message-Badge-000] (1/3): 107 bytes.
Tue, 03 Jan 2012 03:13:56 +0100 ApnsPHP[13049]: INFO: Disconnected.
Here is three cases you can check at your end:-
Make sure that you have used the right production certificate on your server side. since we need to create two different certificates for production and sandbox. make sure you are using correct certificate on server.
second you can check that you have use the right gateway and port number on server side. Since gateway for production and sandbox are different one. Gateway used for production is:- gateway.push.apple.com. and also you are using correct password on server for your certificate your have used on your server.
third you can check if the notification on your device is enabled or not. You need to enable it on your iPhone as well. Make sure that is on your device.
Let me know if it works for you.
For me, i struggle this for days. Using correct production certificate and key, and also correct gateway to send the message to my developing iPhone, it sent successfully in sandbox mode, but failed with production mode. It's because there are also two kinds of device token, the testing iPhone device token is sandbox token, can not be used in the production mode. It's better to use another device's token to test the production APNs.
The detailed explanation is here
The most common problem is an invalid device token. If the token came from the sandbox
environment, such as when you are testing a development build in house, you cannot send it
to the production push service. Each push environment will issue a different token for the
same device or computer. If you do send a device token to the wrong environment, the push
service will see that as an invalid token and discard the notification.
See answer in https://stackoverflow.com/a/11623162/496222
In short: make sure both SSL certificates are in a separate PEM file. Having a single PEM file with both sandbox and production certificate will cause either environment to fail.
please also check whether your App Id enabled push notification
This solved my issue, ensure setting correct value for kGGLInstanceIDAPNSServerTypeSandboxOption
.
For Development mode set to YES and For production mode 'NO'.