immobiliare / ApnsPHP

ApnsPHP: Apple Push Notification & Feedback Provider
BSD 3-Clause "New" or "Revised" License
1.44k stars 452 forks source link

Push to many #92

Open jeremylagrue opened 9 years ago

jeremylagrue commented 9 years ago

Hi, I'm in trouble with push to many and I'm probably doing something wrong. My main question is : Is it a good idea to use it to send more than 1000 push ? 15k for example ?

Currently I'm trying to work this way, and using log but ApnsPHP stop after about 1 sec of push sending and about 100 messages. Always this number after a few tests and I don't really understand. I'm expecting to discover if it comes from ApnsPHP or something else in my code.

my code :

// Instanciate a new ApnsPHP_Push object
$push = new ApnsPHP_Push(
    ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
    'server_certificates_bundle_sandbox.pem'
);
// Set the Root Certificate Autority to verify the Apple remote peer
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
$push->connect();
for ($i = 1; $i <= 100000; $i++) {
    // Instantiate a new Message with a single recipient
    $message = new ApnsPHP_Message(VALID_TOKEN);
    // Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
    // over a ApnsPHP_Message object retrieved with the getErrors() message.
    $message->setCustomIdentifier(sprintf("Message-Badge-%03d", $i));
    // Set badge icon to "3"
    $message->setBadge($i);
    // Add the message to the message queue
    $push->add($message);
    // Send messages in the message queue every 20
    if ($i%20 == 0 && $i > 0) {
        $push->send();
    }
}

// Send all messages left in the message queue
$push->send();
// Disconnect from the Apple Push Notification Service
$push->disconnect();
// Examine the error message container
$aErrorQueue = $push->getErrors();
if (!empty($aErrorQueue)) {
    var_dump($aErrorQueue);
}

my log : https://gist.githubusercontent.com/jeremylagrue/781e98f70d3fa5d26440/raw/c6f2c8de38173240ed44ac9061cbec64ad8f99ac/log.text

So it just stop... Any idea that can help ? Thank's a lot.