1
sendFCM('Уведомление', $account->getFullname().' хочет с вами подружиться.\n\nНажмите на уведомление, чтобы принять или отклонить заявку', $profileInfo['FCM'], '/account/notifications');

Пробовал \n, но пользователю так и приходит:

Вася Пупкин хочет с вами подружиться.\n\nНажмите на уведомление, чтобы принять или отклонить заявку

function sendFCM($title, $msg, $token, $urls = '') {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
        'to' => $token,
        'notification' => array (
                "body" => $msg,
                "title" => $title,
                "sound" => "default",
                'priority' => 'high',
                "icon" => "myicon",
        ),
        'data' => array (
                "url" => $urls
        )
);
$fields = json_encode($fields);
$headers = array (
        'Authorization: key=' . "122342",
        'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

$result = curl_exec($ch);
curl_close($ch);
}

2 ответа 2

0

Попробуйте использовать html тэг

<br />

Посмотрите ссылку может быть пригодиться

1
0

Обычный перевод в коде помог

sendFCM('Уведомление', $account->getFullname().' хочет с вами подружиться.

Нажмите на уведомление, чтобы принять или отклонить заявку', $profileInfo['FCM'], '/account/notifications');

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.