Push notifications do not work with my app on the App Store. With my application in development, push notifications work.
I think I should have tested through the deployment of Ad Hoc. Anyway, this is what I know ...
Application id
my app id is com.MyName.My-App
It has push notifications for development and distribution.

APN Certificates
I have both development and distribution certificates. This is the Dist that I care about.

He has the name com.MyName.My-App
Export to PEM
I selected both Cert and private key and exported it as follows:

and password protected it.
Then i ran
openssl pkcs12 -in Certificates.p12 -out pushcert.pem -nodes -clcerts
providing a password and successfully receiving pushcert.pem output.
Download application
I cleared the server-side device token for my device, downloaded the application from the application store, opened it and received push notifications, and then logged into my server to check the token of my device. Now I have the token of my device. I ran this simple php script (which works when I deliver the token of my development device) but does not work with the token of my device.
<?php // Put your device token here (without spaces): $deviceToken = 'myProductionDeviceTokenInHere'; // Put your private key passphrase here: $passphrase = 'myPasswordIsInHere'; // Put your alert message here: $message = 'Test'; //////////////////////////////////////////////////////////////////////////////// $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'pushcert.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer'); // Open a connection to the APNS server $fp = stream_socket_client( 'ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); if (!$fp) exit("Failed to connect: $err $errstr" . PHP_EOL); echo 'Connected to APNS' . PHP_EOL; // Create the payload body $body['aps'] = array( 'alert' => $message, 'sound' => 'default' ); // Encode the payload as JSON $payload = json_encode($body); // Build the binary notification $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload; // Send it to the server $result = fwrite($fp, $msg, strlen($msg)); if (!$result) echo 'Message not delivered' . PHP_EOL; else echo 'Message successfully delivered' . PHP_EOL; // Close the connection to the server fclose($fp);
Why does he fail? It works with the token of my development device, but not with the token of my product. Didn't I do something right?