$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
'PushCertificates.pem'
);
$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
$push->connect();
$message = new ApnsPHP_Message();
$message->setBadge(intval($Badge));
$message->setSound($Sound);
$message->setText($MessageText);
//$deviceTokens contains DeviceTokens as an arry :)
if(count($deviceTokens)>0){
foreach($deviceTokens as $deviceToken){
try{
$message->addRecipient($deviceToken);
}catch (Exception $ex) {
//To Do: Invalid device token. Remove it form the system.
}
}
$push->add($message);
$push->send();
}
$push->disconnect();