It's a bit vague to say that it's working with 'a simple php app'. With some more information on the difference between the flow of events on the server and the 'php app', we could probably draw some more reasonable conclusions.
Apart from that, if you haven't already, check out this great tutorial by Ali Hafizji from raywenderlich (two parts). It has a detailed explanation of pretty much everything you need, I have used it myself a couple of times(looks like it has been updated since then though). You say you are installing the .p12 on the server, while I'm pretty sure he's converting it to a .pem-file along with the private key.
Also make sure the server is using the correct tokens, as your device's token is different in development from what it is in distribution.
You should also put some health-checks server-side (in the .php or whatever you are using to establish the connection to gateway.push.apple.com
) to make sure your server is actually sending anything.
I.E if you're using mysql to get access to your tokens, put down a if(!$connection){die(mysql_error());}
or something. This should also be done when establishing the connection to Apple. With php and stream_socket_client, you could put something like this:
$fp = stream_socket_client(
'ssl://gateway.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);//$ctx=Stream context
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
And the actual pushing of the notification, or at least the php-way I've been using, fwrite()
returns a boolean for wether it was successful or not, so you can do $result = fwrite($fp, $msg, strlen($msg));
, and $result
will be 0 if it fails.
Also make sure you're connected to the system you intend to use(sandbox or not). I might be way off here, but I think I once tried to send notifications to my device with production-profile when connecting to Apple's Sandbox-system, and didn't receive anything. You said your certificates were 'development', double-check that everything else is too.
Then again, I'm having this .php-code on my server, and I'm not completely sure what you meant by 'simple php-app works, but server doesn't'.