Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'Kreait\Firebase\Messaging\RawMessageFromArray' not found #15

Closed
chimit opened this issue Feb 2, 2020 · 2 comments
Closed

Class 'Kreait\Firebase\Messaging\RawMessageFromArray' not found #15

chimit opened this issue Feb 2, 2020 · 2 comments

Comments

@chimit
Copy link

chimit commented Feb 2, 2020

// MyNotification.php
public function toFcm($notifiable)
{
    return CloudMessage::fromArray([
        'notification' => [
            'body' => 'This is an FCM notification message!',
            'title' => 'FCM Message',
        ],
        'data' => [
            'foo' => 'bar',
        ],
        'android' => [
            'ttl' => '3600s',
            'notification' => [
                'icon' => 'stock_ticker_update',
                'color' => '#f45342',
            ],
        ],
        'apns' => [
            'payload' => [
                'aps' => [
                    'badge' => 100,
                ],
            ],
        ],
    ]);
}
// FcmChannel.php
namespace App\Channels;

use Illuminate\Notifications\Notification;
use Kreait\Laravel\Firebase\Facades\FirebaseMessaging;

class FcmChannel
{
    /**
     * Send the given notification.
     *
     * @param  mixed  $notifiable
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return void
     */
    public function send($notifiable, Notification $notification)
    {
        $message = $notification->toFcm($notifiable);

        FirebaseMessaging::sendMulticast($message, $notifiable->routeNotificationFor('fcm', $notification));
    }
}

Get an error:

[2020-02-02 10:11:40] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Kreait\Firebase\Messaging\RawMessageFromArray' not found in /home/vagrant/Code/lumen/vendor/kreait/firebase-php/src/Firebase/Messaging/Http/Request/SendMessageToTokens.php:36
@jeromegamez
Copy link
Member

Strange 🤔... Just to be sure - are you on the latest versions of the Laravel package and the Admin SDK? You can check with

composer show | grep kreait

The latest Laravel package is 1.3.0 and the SDK is 4.39.1. If you're on the latest versions, could you also try a composer dump-autoload?

The class in question existed for quite some time already, so I hope it's the autoloader being incomplete for whatever reason 😅.

Please let me know if this worked.

@chimit
Copy link
Author

chimit commented Feb 16, 2020

Thanks, it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants