dongwuxie5112 2016-09-12 22:54
浏览 72

iOS推送不会使用多个设备ID

I am fetching an array of device_ids using PHP, and sending iOS pushes to each of them with this code -
Question - the devices received pushes when array of device_ids (deviceTokens) was 2-3 device_ids. But deviecs did not receive push notifications when deviceTokens array was ~300 device_id long. What could be the issue? I am new to PHP

(This question has been asked a few times but answers did not reflect problem I am facing)

$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);
  • 写回答

1条回答 默认 最新

  • dove2199 2017-06-09 07:31
    关注

    Similar issues we had , Cross checking all device id in the database we found device id as "Simulator" which is device id of virtual device in the xcode. During development DEV team might have tested in Simulator and sooner APNS identifies this id , it rejects all request. May be specific issues only to us , cross checking will help.

    评论

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装