3
votes

I am implementing push notifications in my application, in the development part it is working fine, and I receive push notifications well. When I decided to publish it in the app store, I implemented it for distribution (I use the certificate and provisioning profile for distribution), I made the same steps and I converted the .p12 files to .pem through shall, and I combine the certificate.pem and key.pem to another file ck.pem. In the PHP file, I did the following:

$passphrase = 'The passphrase I put it in the shall';

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

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

I already changed sandbox to ssl://gateway.push.apple.com:2195 in my php.

I created production.pem with this steps.

$ openssl x509 -in aps_developer_identity.cer -inform der 
    -out PushChatCert.pem

$ openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12

Enter Import Password: MAC verified OK Enter PEM pass phrase: Verifying - Enter PEM pass phrase:

$ cat PushChatCert.pem PushChatKey.pem > ck.pem

and I uploade my ck.pem to my shared host. It is nothing errors but it does not push notification.

In my php it said : Connected to APNS Message successfully delivered

2
how did you solve your problem...I have the same issue...Push notifications on development mode arrive, on production modo they did not. If I test the production certificate generated with the production apple link, telnet responds successfully. What I do wrong?prelite
so many things, you have to consider it which are: make sure that u have updated the new profiles and passphrase and sandbox, and when you have to try do not send the push for a development device token, because the development device token is different from the production one!Fatima

2 Answers

0
votes

You probably use wrong deviceToken. Remember that production deviceToken and development deviceToken are different!

You should log your deviceToken and then iPhone Configuration Utility will log you correct production deviceToken.

0
votes

I believe in server side not using the distribution PEM file. The main fundamental rule is App and server should run in same mode.If your app is running in debug mode then server also should also use the development PEM file and same like if your app is running in release mode then server also should use distribution PEM file.