/** * Adds a message to the message queue. * * @param $message @type \ApnsPHP\Message The message. */ public function add(\ApnsPHP\Message $message) { $sMessagePayload = $message->getPayload(); $nRecipients = $message->getRecipientsNumber(); $nMessageQueueLen = count($this->_aMessageQueue); for ($i = 0; $i < $nRecipients; $i++) { $nMessageID = $nMessageQueueLen + $i + 1; $this->_aMessageQueue[$nMessageID] = array('MESSAGE' => $message, 'BINARY_NOTIFICATION' => $this->_getBinaryNotification($message->getRecipient($i), $sMessagePayload, $nMessageID, $message->getExpiry()), 'ERRORS' => array()); } }
/** * Get the payload dictionary. * * @return @type array The payload dictionary. */ protected function _getPayload() { $aPayload = parent::_getPayload(); $aPayload['aps']['alert'] = array(); if (isset($this->_sText) && !isset($this->_sLocKey)) { $aPayload['aps']['alert']['body'] = (string) $this->_sText; } if (isset($this->_sActionLocKey)) { $aPayload['aps']['alert']['action-loc-key'] = $this->_sActionLocKey == '' ? null : (string) $this->_sActionLocKey; } if (isset($this->_sLocKey)) { $aPayload['aps']['alert']['loc-key'] = (string) $this->_sLocKey; } if (isset($this->_aLocArgs)) { $aPayload['aps']['alert']['loc-args'] = $this->_aLocArgs; } if (isset($this->_sLaunchImage)) { $aPayload['aps']['alert']['launch-image'] = (string) $this->_sLaunchImage; } return $aPayload; }