示例#1
0
 foreach ($res1 as $row) {
     $dt = $row['device_token'];
     //echo $dt."<br>.";
     if (strlen($row['device_token']) == 64) {
         //echo $row['device_token']."<br><hr>";
         $message = new ApnsPHP_Message_Custom($dt);
         // 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("Message-Badge-1");
         // Set badge icon to "3"
         $message->setBadge(1);
         // Set a simple welcome text
         $message->setText($row['msg']);
         // Play the default sound
         $message->setSound();
         $message->setCat($row['cat']);
         $message->setCustomProperty('ticket_hash', $row['ticket_hash']);
         //$message->setCustomProperty('category', 'lock');
         /*
         $message->setCustomProperty('a', $row['ticket_action']);
         $message->setCustomProperty('id', $row['ticket_id']);
         $message->setCustomProperty('ui', $row['ticket_user_init']);
         */
         // Set the expiry value to 30 seconds
         $message->setExpiry(300);
         // Add the message to the message queue
         $push->add($message);
         // Send all messages in the message queue
         $stmt2 = $dbConnection->prepare('update push_pool set status = :s where id=:id');
         $stmt2->execute(array(':s' => '1', ':id' => $row['id']));
     }