php - iOS push not going to multiple device IDs -
i fetching array of device_ids using php, , sending ios pushes each of them code -
question - devices received pushes when array of device_ids (devicetokens
) 2-3 device_ids
. deviecs did not receive push notifications when devicetokens
array ~300 device_id
long. issue? new php
(this question has been asked few times answers did not reflect problem facing)
$customers_ios = "select * `gcm_user` `gcmregios` <> '0' , `preference` = '1'"; $c_ios = mysql_query($customers_ios); while($bd = mysql_fetch_array($c_ios)) { $devicetokens[]= $bd['gcmregios']; } $arrlength = count($devicetokens); //echo $arrlength; // put private key's passphrase here: $passphrase = 'mypassphrase';//'pushnotification'; //adhoc_id 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 connection 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 payload body $body['aps'] = array( 'alert'=> $title, 'message' => array('adhoc' => array('adhoc_id' => $adhoc_id, 'adhoc_title' => $title, 'adhoc_description' => $message, ) ), 'sound'=>'default' ); // encode payload json $payload = json_encode($body); foreach($devicetokens $ios_token){ $msg = chr(0) . pack("n",32) . pack('h*', str_replace(' ', '', $ios_token)) . pack("n",strlen($payload)) . $payload; $result = fwrite($fp, $msg); } // close connection server fclose($fp);
similar issues had , cross checking device id in database found device id "simulator" device id of virtual device in xcode. during development dev team might have tested in simulator , sooner apns identifies id , rejects request. may specific issues , cross checking help.
Comments
Post a Comment