1. Go to this page and download the library: Download grohiro/laravel-firebase library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grohiro / laravel-firebase example snippets
use Illuminate\Notifications\Notification;
use Grohiro\Laravel\FCM\FirebaseChannel;
use paragraph1\phpFCM\Message;
use paragraph1\phpFCM\Recipient\Device;
use paragraph1\phpFCM\Notification;
/**
* @see https://laravel.com/docs/5.5/notifications#custom-channels
*/
class PushMessage extends Notification
{
public function via($notifiable)
{
return [FirebaseChannel::class];
}
public function toFcmMessage($user)
{
// @see https://github.com/Paragraph1/php-fcm
$note = new Notification('test title', 'testing body');
$note->setIcon('notification_icon_resource_name')
->setColor('#ffffff')
->setBadge(1);
$message = new Message();
$message->addRecipient(new Device($user->user_device_token));
$message->setNotification($note)
->setData(array('someId' => 111));
return $message;
}
}