fix: 推送标题存在换行时不显示

This commit is contained in:
kuaifan 2024-02-28 15:04:31 +08:00
parent 779b32e8ad
commit cc862741dc

View File

@ -31,6 +31,16 @@ class UmengAlias extends AbstractModel
{ {
protected $table = 'umeng_alias'; protected $table = 'umeng_alias';
/**
* 推送内容处理
* @param $string
* @return string
*/
private static function specialCharacters($string)
{
return str_replace(["\r\n", "\r", "\n"], '', $string);
}
/** /**
* 获取推送配置 * 获取推送配置
* @return array|false * @return array|false
@ -73,9 +83,9 @@ class UmengAlias extends AbstractModel
return false; return false;
} }
// //
$title = $array['title'] ?: ''; // 标题 $title = self::specialCharacters($array['title'] ?: ''); // 标题
$subtitle = $array['subtitle'] ?: ''; // 副标题iOS $subtitle = self::specialCharacters($array['subtitle'] ?: ''); // 副标题iOS
$body = $array['body'] ?: ''; // 通知内容 $body = self::specialCharacters($array['body'] ?: ''); // 通知内容
$description = $array['description'] ?: 'no description'; // 描述 $description = $array['description'] ?: 'no description'; // 描述
$extra = is_array($array['extra']) ? $array['extra'] : []; // 额外参数 $extra = is_array($array['extra']) ? $array['extra'] : []; // 额外参数
$seconds = intval($array['seconds']) ?: 86400; // 有效时间(单位:秒) $seconds = intval($array['seconds']) ?: 86400; // 有效时间(单位:秒)