Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:16:44+00:00 2026-06-08T18:16:44+00:00

I know that there are many posts on SO that address this problem, unfortunately

  • 0

I know that there are many posts on SO that address this problem, unfortunately I’m not that advanced in PHP programming and I have a question that hasn’t been answered somewhere else:

Many of the tutorials for Apple Push Notifications create a connection via stream_socket_client(). But most of them are lacking the flag “STREAM_CLIENT_PERSISTENT”. Would this flag make the connection really persistent? If so when would it be closed? The documentation says it will stay connected also on page reloads. Is this depending on sessions?

The version without this flag is working but I’m afraid the APNS will block me as soon as I put in the production certificates etc. (described here).
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:16:45+00:00Added an answer on June 8, 2026 at 6:16 pm

    As per the PHP documentation on Predefined Constants, using STREAM_CLIENT_PERSISTENT with the APNS connection should keep the connection active between page loads. This is a requirement for the APNS connection, as it WILL throttle you as it considers any disconnection after sending a payload a potential Denial of Service attack.

    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 PHPXMLRPC, so you will have to download that package.

    <?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" => array("alert" => "Hello User 1" )), array("aps" => array("alert" => "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->setDebug(2);
    
        # The response
        $response = &$client->send($echoString);
    
        # Check if response is good
        if (! $response->faultCode())
            print "\nReturned string is: " . php_xmlrpc_decode($response->value()) . "\n";
        else
            print "An error occurred: \nCode: " . $response->faultCode() . " Reason: '" . htmlspecialchars($response->faultString()) . "'\n";
    }
    
    ?>
    

    SOURCE: How to get started with APNS for iPhone or iTouch

    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.

    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 APIs to talk to your clients.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are many posts about this on Stackoverflow, but this one
I know that there are many different questions about this sort of topic on
Firstly I know that there are many question and solutions to correct thread marshalling
It's my first question on SO. I know that there were many topics on
I know that there are some threads have a similar issue with this thread.
many thanks for this site. many posts have helped me recently. this window question
I have read many posts and blogs about rewriting and I know there is
I know there are many posts about this issue however I cannot find one
I know there have been many posts on jquery vs ajax toolkit and I
First of all... Sorry for this post. I know that there are many many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.