Apple Push Notification Service APNS - Notifications Not Received

I am trying to add push notifications to my application. I use a special profile. My application does not have a wildcard. I am using the following php code ...

$deviceToken="****";masked $time = time(); $apnsHost = 'gateway.sandbox.push.apple.com'; $apnsPort = 2195; $apnsCert = 'apns-dev-maui.pem'; $streamContext = stream_context_create(); stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert); $apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext); if($apns) { echo "Connection Established<br/>"; $payload = array(); $payload['aps'] = array('alert' => 'It works!!', 'badge' => 1, 'sound' => 'default'); $payload = json_encode($payload); $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload; print "sending message :" . $apnsMessage . "<br/>"; print "sending payload :" . $payload . "<br/>"; fwrite($apns, $apnsMessage); } else { echo "Connection Failed"; echo $errorString; echo $error; } // socket_close($apns); fclose($apns); 

Connection errors are not generated. Nothing seems to get out of the feedback channel.

I got deviceTokens from the organizer console and the NSLog team. Notifications for this application appear in my settings menu.

I have ATT 3G and the old 2G, which I use as an iPod. None of them work.

Without errors, to see, I have no ideas. Does anyone have an understanding?

Jennifer

+7
php iphone push-notification apple-push-notifications
source share
2 answers

I finally figured it out. I used Sandbox with an AdHoc training profile. Ad Hoc seems to be considered production, not development. I created a test certificate of production, installed it and voila! He works.

+24
source share

Mups answer is correct. I wanted to add an add situation that would have the same problem (if it is useful to anyone else). I had a push setting, and it worked exactly on 1 iphone (and not on others). It was very puzzling. The problem was that the 1 iphone that worked had a "debug" version of the installed program, in which others had an "ad hoc" version. Our APNS server has been configured to use the development certificate and gateway.sandbox.push.apple.com

I changed the certificate on the server to the "production" certificate, and the host on gateway.push.apple.com

(then removed all provisioning profiles on all devices and installed the ad hoc version of the program)

And we were good to go.

+6
source share

All Articles