You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to sen multiple message with sendMulticast from Kreait\Firebase\Messaging I recive an exception - _Unsupported message type. Use an array or a class implementing %sKreait\Firebase\Messaging\Message, despite the fact that I use CloudMessage or Notification.
use Kreait\Firebase\Messaging;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Message;
use Kreait\Firebase\Messaging\Notification;
.....
$message = [
'title' => __('mobile_notifications_messages.posts.' . $eventName, [
$author,
$post->title,
]),
'body' => 'Something'
];
$message = Notification::fromArray($message);
$response = $this->messaging->sendMulticast($message, $deviceTokens);
I use Laravel 5.8
Could you please help me with this?
The text was updated successfully, but these errors were encountered:
The first $message array is actually the notification data, not a full message. You have two possibilities here:
Write the whole message as an array and use CloudMessage
$messageData = [
'notification' => [ // <- This is the difference to your code'title' => __('mobile_notifications_messages.posts.' . $eventName, [
$author,
$post->title,
]),
'body' => 'Something'
]
];
$message = CloudMessage::fromArray($messageData);
Write only the notification as an array and append it to a new CloudMessage
// Note that this variable is named $notification and passed// to a new $message below$notification = [
'title' => __('mobile_notifications_messages.posts.' . $eventName, [
$author,
$post->title,
]),
'body' => 'Something'
];
$message = CloudMessage::new()->withNotification($notification);
Hello!
When I try to sen multiple message with sendMulticast from Kreait\Firebase\Messaging I recive an exception - _Unsupported message type. Use an array or a class implementing %sKreait\Firebase\Messaging\Message, despite the fact that I use CloudMessage or Notification.
I use Laravel 5.8
Could you please help me with this?
The text was updated successfully, but these errors were encountered: