Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a tested php5 version of jessecurry's test-script. It uses the '<a href="http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1" rel="nofollow">enhanced message format</a>', and tries to catch and display errors from apple. This might give an indication as to what's wrong with your messages.</p> <pre><code>// Settings $deviceToken = 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'; $apnsCert = 'apns-dev.pem'; $apnsHost = 'gateway.sandbox.push.apple.com'; $apnsPort = 2195; // Prepare payload $payload = array( 'aps' =&gt; array( 'alert' =&gt; 'Hi, this is an alert!', 'badge' =&gt; 8 ) ); $payload = json_encode($payload); print($payload . "\n"); // Connect to Apple Push Notification server $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) { die('Error creating ssl socket'); } // Don't block on reading from the socket stream_set_blocking ($apns, 0); // Send payload in enhanced message format ( http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1 ) $apnsMessage = // Command "1" chr(1) // Identifier "88" . pack('N', 88) // Expiry "tomorrow" . pack('N', time() + 86400) // Token length . chr(0) . chr(32) // Device token . pack('H*', str_replace(' ', '', $deviceToken)) // Payload length . chr(0) . chr(strlen($payload)) // Actual payload . $payload . $payload; fwrite($apns, $apnsMessage); // Pause for half a second to check if there were any errors during the last seconds of sending. usleep(500000); checkAppleErrorResponse($apns); // Close connection -- apple would prefer that we keep // a connection open and push data as needed. fclose($apns); function checkAppleErrorResponse($apns) { $responseBinary = fread($apns, 6); if ($responseBinary !== false &amp;&amp; strlen($responseBinary) == 6) { print( "\n" .'Error message recieved from Apple.'."\n" .'For the meaning, refer to: "Provider Communication with Apple Push Notification Service"'."\n" ); $response = unpack('Ccommand/Cstatus_code/Nidentifier', $responseBinary); var_dump($response); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload