在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
http://blog.csdn.net/gnicky/article/details/7544202 1. URL是不一样的,端口是2196 2. 使用同样的Certificate,建立安全连接,接受数据,直到数据不存在,类似table select操作 3.每条纪录是一个token,server然后要删除这些device token纪录 Access to the feedback service takes place through a binary interface similar to that used for sending push notifications. You access the production feedback service via Once you are connected, transmission begins immediately; you do not need to send any command to APNs. Begin reading the stream written by the feedback service until there is no more data to read. The received data is in tuples having the following format: Binary format of a feedback tuple http://code.google.com/p/apns-php/
Classes hierarchy看一下feedback的代码: public function receive() { $nFeedbackTupleLen = self::TIME_BINARY_SIZE + self::TOKEN_LENGTH_BINARY_SIZE + self::DEVICE_BINARY_SIZE; $this->_aFeedback = array(); $sBuffer = ''; while (!feof($this->_hSocket)) { $this->_log('INFO: Reading...'); $sBuffer .= $sCurrBuffer = fread($this->_hSocket, 8192); $nCurrBufferLen = strlen($sCurrBuffer); if ($nCurrBufferLen > 0) { $this->_log("INFO: {$nCurrBufferLen} bytes read."); } unset($sCurrBuffer, $nCurrBufferLen); $nBufferLen = strlen($sBuffer); if ($nBufferLen >= $nFeedbackTupleLen) { $nFeedbackTuples = floor($nBufferLen / $nFeedbackTupleLen); for ($i = 0; $i < $nFeedbackTuples; $i++) { $sFeedbackTuple = substr($sBuffer, 0, $nFeedbackTupleLen); $sBuffer = substr($sBuffer, $nFeedbackTupleLen); $this->_aFeedback[] = $aFeedback = $this->_parseBinaryTuple($sFeedbackTuple); $this->_log(sprintf("INFO: New feedback tuple: timestamp=%d (%s), tokenLength=%d, deviceToken=%s.", $aFeedback['timestamp'], date('Y-m-d H:i:s', $aFeedback['timestamp']), $aFeedback['tokenLength'], $aFeedback['deviceToken'] )); unset($aFeedback); } } $read = array($this->_hSocket); $null = NULL; $nChangedStreams = stream_select($read, $null, $null, 0, $this->_nSocketSelectTimeout); if ($nChangedStreams === false) { $this->_log('WARNING: Unable to wait for a stream availability.'); break; } } return $this->_aFeedback; } /** * Parses binary tuples. * * @param $sBinaryTuple @type string A binary tuple to parse. * @return @type array Array with timestamp, tokenLength and deviceToken keys. */ protected function _parseBinaryTuple($sBinaryTuple) { return unpack('Ntimestamp/ntokenLength/H*deviceToken', $sBinaryTuple); } |
2022-08-17
2022-11-06
2022-08-17
2022-07-29
2022-07-18
请发表评论