- Модуль: pull
- Путь к файлу: ~/bitrix/modules/pull/lib/push/message/applemessage.php
- Класс: BitrixPullPushMessageAppleMessage
- Вызов: AppleMessage::getPayload
public function getPayload()
{
$sJSONPayload = str_replace(
'"' . self::APPLE_RESERVED_NAMESPACE . '":[]',
'"' . self::APPLE_RESERVED_NAMESPACE . '":{}',
json_encode($this->_getPayload(), static::JSON_OPTIONS)
);
$nJSONPayloadLen = strlen($sJSONPayload);
if ($nJSONPayloadLen <= $this->payloadMaxSize)
{
return $sJSONPayload;
}
if (!$this->_bAutoAdjustLongPayload)
{
return false;
}
$text = $this->text;
$useSenderText = false;
if(array_key_exists("senderMessage", $this->customProperties))
{
$useSenderText = true;
$text = $this->customProperties["senderMessage"];
}
$nMaxTextLen = $nTextLen = strlen($text) - ($nJSONPayloadLen - $this->payloadMaxSize);
if ($nMaxTextLen <= 0)
{
return false;
}
while (strlen($text) > $nMaxTextLen)
{
$text = substr($text, 0, --$nTextLen);
}
if($useSenderText)
{
$this->setCustomProperty("senderMessage", $text);
}
else
{
$this->setText($text);
}
return $this->getPayload();
}