kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
1.05k stars 169 forks source link

Call to undefined method Messaging::createMessaging() #24

Closed diadal closed 4 years ago

diadal commented 4 years ago

try to make samples of Laravel calls none of this working

ymfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Kreait\Firebase\Messaging::createMessaging()

$messaging =  app('firebase.messaging')->createMessaging();
        $message = CloudMessage::withTarget('token', $id)
                ->withNotification(Notification::create('testing', 'working ok'))
                ->withData(['test' => 'value']);

        $m = $messaging->send($message);
jeromegamez commented 4 years ago
$messaging = app('firebase.messaging');
diadal commented 4 years ago

not working Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App\Http\Controllers\CloudMessage' not found



$messaging =  app('firebase.messaging');

        $message = CloudMessage::withTarget('token', $id)
                ->withNotification(Notification::create('testing', 'working ok'))
                ->withData(['test' => 'value']);

        $m = $messaging->send($message);

        return [$m];

``
jeromegamez commented 4 years ago

You didn‘t

use Kreait\Firebase\Messaging\CloudMessage;
diadal commented 4 years ago

no am only following the readme file try make some little samples for laravel like this use Kreait\Firebase\Messaging\CloudMessage;

Screenshot 2020-02-24 at 08 28 37
diadal commented 4 years ago

now this Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App\Http\Controllers\Notification' not found

diadal commented 4 years ago

please which of the Notification needed

jeromegamez commented 4 years ago

Please read the documentation at https://firebase-php.readthedocs.io/

How to create notifications (includes the use statement): https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html#adding-a-notification

How to create cloud messages (includes the use statement): https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html#getting-started

The only difference between the direct usage of the SDK and this package is that you don‘t need to invoke the SDK‘s factory to instantiate the components.

So, instead of writing

$messaging = (new Factory)->withServiceAccount('...')->createMessaging();

you can write

$messaging = app('firebase.messaging');

The same with all other components. After that, you‘ll find everything you need in the docs linked above.

diadal commented 4 years ago

working now use Kreait\Firebase\Messaging\Notification; thanks for your time