Ejemplo n.º 1
0
 /**
  * Returns batch of the message
  * @return string
  */
 public function getBatch()
 {
     $data = array("data" => array('contentTitle' => $this->title, "contentText" => $this->text, "messageParams" => $this->customProperties), "time_to_live" => $this->expiryValue, "registration_ids" => $this->deviceTokens);
     $data = CPushManager::_MakeJson($data, "", true);
     $batch = "Content-type: application/json\r\n";
     $batch .= "Content-length: " . CUtil::BinStrlen($data) . "\r\n";
     $batch .= "\r\n";
     $batch .= $data;
     return base64_encode($batch);
 }
Ejemplo n.º 2
0
 public function getPayload()
 {
     $sJSONPayload = str_replace('"' . self::APPLE_RESERVED_NAMESPACE . '":[]', '"' . self::APPLE_RESERVED_NAMESPACE . '":{}', CPushManager::_MakeJson($this->_getPayload(), "", false));
     $nJSONPayloadLen = CUtil::BinStrlen($sJSONPayload);
     if ($nJSONPayloadLen > $this->payloadMaxSize) {
         if ($this->_bAutoAdjustLongPayload) {
             $nMaxTextLen = $nTextLen = CUtil::BinStrlen($this->text) - ($nJSONPayloadLen - $this->payloadMaxSize);
             if ($nMaxTextLen > 0) {
                 while (CUtil::BinStrlen($this->text = CUtil::BinSubstr($this->text, 0, --$nTextLen)) > $nMaxTextLen) {
                 }
                 return $this->getPayload();
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     return $sJSONPayload;
 }
Ejemplo n.º 3
0
 public function getPayload()
 {
     $sJSONPayload = str_replace('"' . self::APPLE_RESERVED_NAMESPACE . '":[]', '"' . self::APPLE_RESERVED_NAMESPACE . '":{}', CPushManager::_MakeJson($this->_getPayload(), "", false));
     $nJSONPayloadLen = CUtil::BinStrlen($sJSONPayload);
     if ($nJSONPayloadLen > self::PAYLOAD_MAXIMUM_SIZE) {
         if ($this->_bAutoAdjustLongPayload) {
             $nMaxTextLen = $nTextLen = CUtil::BinStrlen($this->text) - ($nJSONPayloadLen - self::PAYLOAD_MAXIMUM_SIZE);
             if ($nMaxTextLen > 0) {
                 while (CUtil::BinStrlen($this->text = CUtil::BinSubstr($this->text, 0, --$nTextLen)) > $nMaxTextLen) {
                 }
                 return $this->getPayload();
             } else {
                 throw new Exception("JSON Payload is too long: {$nJSONPayloadLen} bytes. Maximum size is " . self::PAYLOAD_MAXIMUM_SIZE . " bytes. The message text can not be auto-adjusted.");
             }
         } else {
             throw new Exception("JSON Payload is too long: {$nJSONPayloadLen} bytes. Maximum size is " . self::PAYLOAD_MAXIMUM_SIZE . " bytes");
         }
     }
     return $sJSONPayload;
 }