iOS不会推送到多个设备id


iOS push not going to multiple device IDs

我正在使用PHP获取一个device_ids数组,然后用这个代码-向它们发送iOS推送
问题 - device_ids (deviceTokens)的数组为2-3个device_ids时,设备收到推送。但是当deviceTokens阵列长度为~300 device_id时,设备没有收到推送通知。有什么问题吗?我是PHP的新手

(这个问题已经被问过几次了,但答案并没有反映我所面临的问题)

$customers_ios = "SELECT * FROM `gcm_user` WHERE `gcmregios` <> '0' and `preference` = '1'";
                $c_ios = mysql_query($customers_ios);
                while($bd = mysql_fetch_array($c_ios)) {
                    $deviceTokens[]= $bd['gcmregios'];
                }
                $arrlength = count($deviceTokens);
                //echo $arrlength;
                // Put your private key's passphrase here:
                $passphrase = 'mypassphrase';//'PushNotification';
                //adhoc_id already setup above
                $message = $adhoc_desc;
                $title =  $adhoc_title;

                $ctx = stream_context_create();
                stream_context_set_option($ctx, 'ssl', 'local_cert', 'PushDistCertificates.pem');
                stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
                //'ssl://gateway.sandbox.push.apple.com:2195'
                // Open a connection to the APNS server
                $fp = stream_socket_client(
                  'ssl://gateway.push.apple.com:2195', $err,
                  $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
                if (!$fp)
                    continue;
                // Create the payload body
                $body['aps'] = 
                array(
                    'alert'=> $title,
                    'message' => 
                    array('ADHOC' => 
                        array('ADHOC_ID' => $adhoc_id,
                            'ADHOC_TITLE' => $title,
                            'ADHOC_DESCRIPTION' =>  $message,
                        )
                    ),
                    'sound'=>'default'
                );
                // Encode the payload as JSON
                $payload = json_encode($body);
                foreach($deviceTokens as $ios_token){
                    $msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $ios_token)) . pack("n",strlen($payload)) . $payload;
                    $result = fwrite($fp, $msg); 
                }
                // Close the connection to the server
                fclose($fp);

我们遇到了类似的问题,交叉检查数据库中的所有设备id,我们发现设备id为"Simulator",这是xcode中虚拟设备的设备id。在开发期间,DEV团队可能已经在模拟器中进行了测试,并且APNS很快识别了这个id,它拒绝了所有请求。可能具体问题只针对我们,交叉检查将有所帮助。