title: multiple sending ios push notification doesn't work
body: <p>I get a customized CMS for school (PHP/Mysql/html/CSS/JS). One of the functions in this CMS is sending school info to the mobile applications. For example a teacher can add news for his students and the CMS sends android and iOS push notifications to his students. </p>
  
  <p>The problem is when the system sends multiple iOS notifications, the notifications are not received. (Single iOS notifications work without problem).</p>
  
  <p>The source code of the function:</p>
  
  <pre><code>function send_notification_ios($mesaj, $uye, $link = NULL,$cert = 'combined',$passphrase="passphrase123") {
      $success = 0;
      $failure = 0;
      $error;
      $errorString;
      $keyPath = dirname(__FILE__) . '/' .$cert.'.pem';
  
      $keyPassword = $passphrase;
      $context = stream_context_create();
      if (!stream_context_set_option($context, 'ssl', 'local_cert', $keyPath)){
          return json_encode(array('success' =&gt; 0, 'failure' =&gt; 1, 'reason'=&gt;'stream_context local_cert'));
      }
      if(!stream_context_set_option($context, 'ssl', 'passphrase', $keyPassword)){
          return json_encode(array('success' =&gt; 0, 'failure' =&gt; 1, 'reason'=&gt;'stream_context passphrase'));
      }
  
      $socket = stream_socket_client('ssl://gateway.push.apple.com:2195', $error, $errorString, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $context);
      if (!$socket) {
          return json_encode(array('success' =&gt; 0, 'failure' =&gt; 1, 'reason'=&gt;'soket: '.$error.' '.$errorString.' '.$keyPath.' '.$keyPassword));
      }
      $body['aps'] = array(
              'alert' =&gt; array( 
                  'action-loc-key'    =&gt; "Open",
                  'body'              =&gt; $mesaj
              ),
              'sound' =&gt; 'default',
              'badge' =&gt; 0
          );
      foreach ($uye as $item) {
          $body['aps']['badge'] = (isset($item['badge'])) ? $item['badge'] : 0;
          $body['url'] = (isset($item['url'])) ? $item['url'] : '';
          $encodedData = json_encode($body);
          $binaryString = chr(0).pack('n', 32).pack('H*', $item['apikey']).pack('n', strlen($encodedData)).$encodedData;
          $result = fwrite($socket, $binaryString, strlen($binaryString));
          if (!$result) {
              $failure++;
          } else {
              $success++;
          }
      }
      fclose($socket);
      return json_encode(array('success' =&gt; $success, 'failure' =&gt; $failure, 'reason'=&gt;'fwrite', 'certname'=&gt;$cert));
  }
  </code></pre>
  
  <p>Any help will be appreciated.</p>