Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As per the PHP documentation on <a href="http://php.net/manual/en/stream.constants.php">Predefined Constants</a>, using <strong>STREAM_CLIENT_PERSISTENT</strong> with the APNS connection <em>should</em> keep the connection active between page loads. This is a requirement for the APNS connection, as it <strong>WILL</strong> throttle you as it considers any disconnection after sending a payload a potential Denial of Service attack.</p> <p>Should you have any problems with the client outside of the presisitent connections, you might want to try the following, as it's the best way I've seen to handle an APNS connection thus far within PHP. This uses the client from <a href="http://phpxmlrpc.sourceforge.net/">PHPXMLRPC</a>, so you will have to download that package.</p> <pre><code>&lt;?php include '../vendors/xmlrpc.inc'; $hostName = 'localhost'; # Your services endpoint here. $rpcPath = ''; $port = 7077; if($_GET['action'] == 'provisioning') { $echoString = new xmlrpcmsg( 'provision', array( php_xmlrpc_encode('appid'), php_xmlrpc_encode('/path/to/certificate.pem'), php_xmlrpc_encode('sandbox'), php_xmlrpc_encode(100) ) ); $continue = TRUE; } if($_GET['action'] == 'notify') { $echoString = new xmlrpcmsg( 'notify', array( php_xmlrpc_encode('paparazzme'), php_xmlrpc_encode(array('6bcda...', '7c008...')), php_xmlrpc_encode(array(array("aps" =&gt; array("alert" =&gt; "Hello User 1" )), array("aps" =&gt; array("alert" =&gt; "Hello User 2" )))) ) ); $continue = TRUE; } if($continue == true) { # Create a client handle and send request $client = new xmlrpc_client($rpcPath, $hostName, $port); # A little verbose debug $client-&gt;setDebug(2); # The response $response = &amp;$client-&gt;send($echoString); # Check if response is good if (! $response-&gt;faultCode()) print "\nReturned string is: " . php_xmlrpc_decode($response-&gt;value()) . "\n"; else print "An error occurred: \nCode: " . $response-&gt;faultCode() . " Reason: '" . htmlspecialchars($response-&gt;faultString()) . "'\n"; } ?&gt; </code></pre> <p><strong>SOURCE: <a href="http://www.how2s.org/index.php/How_to_get_started_with_Apple_Push_Notifications_for_iPhone_or_iPhone_Touch">How to get started with APNS for iPhone or iTouch</a></strong></p> <p>I would like to take the time, to point out that, I've not tested any of this code, I do not have an iPhone application right now to test this with, so I can tell you if this actually works.</p> <p>If it is feasable for you, I would recomend that you use Uban Airship instead, as they do provide 250,000 free pushes a month to each of their clients, and that handle the connection to the APN Server for you, from there you use their <a href="http://urbanairship.com/docs/push_index.html">APIs</a> to talk to your clients.</p>
 

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