1. Go to this page and download the library: Download meeeet-dev/larafirebase 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/ */
use Illuminate\Notifications\Notification;
use MeeeetDev\Larafirebase\Messages\FirebaseMessage;
class SendBirthdayReminder extends Notification
{
/**
* Get the notification's delivery channels.
*/
public function via($notifiable)
{
return ['firebase'];
}
/**
* Get the firebase representation of the notification.
*/
public function toFirebase($notifiable)
{
$deviceTokens = [
'{TOKEN_1}',
'{TOKEN_2}'
];
return (new FirebaseMessage)
->withTitle('Hey, ', $notifiable->first_name)
->withBody('Happy Birthday!')
->asNotification($deviceTokens); // OR ->asMessage($deviceTokens);
}
}